Flashing Sonoff TH Elite THR320D via UART resulted in a bootloop that appeared to be power supply and radio related.
- Minimal configuration
- Configuration that was known working from another identical device
- Multiple devices new from the box after testing with stock firmware and Tasmota firmware
- Multiple different power 3.3v supplies (checked with multimeter)
- Battery power
- Mains power
Any configuration that included WiFi or BLE would trigger a bootloop.
Posting this for two reasons:
- I would like to know why flashing ESPHome resulted in a bootloop without this workaround, in hopes of contributing a fix if there is one possible.
- So that others experiencing this issue can find a potential workaround.
I only have a Sonoff TH Elite model THR320D, but I suspect this could apply to these similar Sonoff devices:
- TH Origin - THR316, THR320
- POW Origin - POWR316
- POW Elite - POWR316D, POWR320D
- TH Elite - TH316D, TH320D (this device)
- Smart Switch - TH10, TH16
- High Power Smart Switch - POWR3
- Flash the device with Tasmota via UART.
- Connect the device to mains power.
- Provide WiFi details via Tasmota captive portal.
- Connect to the Tasmota web UI and flash a minimal
esphome (legacy format) configuration with board set to
- Power cycle the device on mains power, wait a few minutes.
- Disconnect mains power.
- Flash the device with
esphome (modern format) and board set to
nodemcu-32s including the WiFi module and SSID / password via UART.
- Connect to mains power.
- Power cycle the device.
- Flash via OTA wirelessly going forward.
I have no idea what causes this problem or why this workaround works. I was able to reproduce the problem with four different units new out of the box and using these steps got me up and running with ESPHome on all of the devices with OTA updates working perfectly.
I must admit, this really does seem to be a power issue but I tried multiple power supplies, multiple outlets, 3.3v battery power, and 3.3v power provided by an ESP32-dev board. In all situations I ended up with a bootloop whenever wireless (WiFi or BLE) tried to start.
I’d love some help figuring out why this is happening.
Found this while hitting similar issues installing Tasmota on SonOff THR320.
The simple fix was to flash from the USB 3.3v supply then switch to AC for the web config. It may be possible to flash with the mains connected but this would be risky (put mildly - just don’t!).
I have seen this before on the ESP8266 modules (I built my own battery powered WiFI/MQTT thermostats using these a few years back) - specifically they use a LOT more power for the initial wifi connection which caused a brownout (reset). The solution was a relatively large electrolytic capacitor on the power lines to smooth things out. I guess this sonoff unit has the same issue and the 3.3v from the USB Serial adapter is not sufficient.
It may be possible to add an electrolytic capacitor (say 220uf 16V at a guess) across the 0V/3.3V power from the USB/Serial unit to work around the issue for flashing and intial tests.
I’m also having trouble with this, with a THR320. Tasmota failed to get even as far into the boot process (on 3v3) as ESPHome, although I’m not really familiar with how much logging to expect from Tasmota. I put it on AC, didn’t see any Tasmota Access Point showing up. I also tried installing ESPHome and powering it from AC, but also got nothing.
I did try erasing the flash before flashing ESHome, thinking that perhaps there was a residual setting somewhere, but that made no difference.
I powered the THR320 from a breadboard power supply (12V to 3V3 via an AMS1117), which should have plenty of capacity for the board, but no difference.
Any other suggestions? Last thing to try is powering it from mains, and putting a UART on it via a USB isolator into a Pi Zero W on a battery, to limit the potential fallout.
So I got it working, by flashing a configuration with only a fallback AP with no credentials to my main WiFi via UART, then powering by AC, connecting using my phone and adding the correct WiFi credentials, then flashing a more full-featured configuration while AC-powered.
It’s VERY strange!
For anyone else that stumbles on this, perhaps try enabling the
debug: component to try and get some information about why it is bootlooping?
Mine has gone into production, so I am unable to try it myself.
Any news on this issue? I’m trying to use esphome on THR316 and see a similar issue. I’m able to use a minimal configuration (AP mode only and powered from mains) but as soon as i connect to a Wifi network it stops working. Home Assistant is able to see the device for a short moment but after that the device is silent. I have not tried the Tasmota workaround yet. Will try to get the logs in a secure way.
I tried to follow your workaround. It fails after step 7. The device connects and disconnects from WiFi network.
In step 4, what is your yaml configuration? I just included esphome/name and esp32/board config (esp32dev). Did you also include WiFi / API configuration?
I also had this problem, but I didn’t need to resort to flashing Tasmota first.
The issue (for me at least) is for sure power related. However, note that the initial flash, powered from the 3v3 line, does succeed. It is simply that the resulting image will not boot until it is connected to mains power, as it resets during wifi initialization.
The steps I followed for flashing are:
- Compile with ‘esphome run .yaml’
- Connect USB Serial device
- Hold down the THR320 button, and plug USB Serial device into PC
- Upload pre-compiled firmware with ‘esphome upload .yaml’
- Release button once upload starts
- Disconnect Serial
- Wire THR320 into mains power.
- Check the logs, with ‘esphome logs .yaml’
I’m currently using a stub config, that looks like this:
# Enable logging
# Enable Home Assistant API
key: !secrets apikey
ssid: !secrets wifissid
password: !secrets wifipwd
# Enable fallback hotspot (captive portal) in case wifi connection fails
password: !secrets wifipwd
If you’re using the HomeAssistant GUI for ESPHome config, the process will be similar. Just connect to mains after the initial bootstrapping in the ESPHome Web portal.
I`m new to the Tasmota world, just started with rolling out
But i have the same issues as described as above
Yesterday i flashed a THR316D with Tasmota using ESP Home via Serial flasher with extra power source attached to 3,3 v pins while flashing
Flashing successful but when i attached the 230 V ac back on i only have a faint ‘auto led’ nothing else.
So i thought i broke it and bought a new device, this time a THR316 (without the display)
But same story, device is down, only the ‘auto’ led at the front is faintly burning
I can reflash however but don’t know what to do now
I this the same problem your having
Thx in advance, appreciate the help
Today i received again a brand new Sonoff THR316D, and before flashing made a backup of the original Sonoff FW using ESPtool using tutorial from here:
This software I restored on the former device I thought I broke
But he works fine, so happy about it
So I know for sure the THR316D and the THR316 both don`t work win the bin files below:
Both stock fw, has anyone a solution for me?
Just seeing this comment now. Unfortunately I don’t know what the configuration looked like. I’ve been using OTA updates fine since I did the workaround.
Could someone please summarize or make clear if the THR316 can be flashed with Tasmota via OTA? And how to do it?
Yes tasmota works fine!
I though something was wrong afther flashing but just needed configuring afterwards.
And this template