Bootloop Workaround for Flashing Sonoff TH Elite (THR316D/THR320D and maybe others) with ESPHome for the first time

Flashing Sonoff TH Elite THR320D via UART resulted in a bootloop that appeared to be power supply and radio related.

I tried:

  • 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

What happened:

Any configuration that included WiFi or BLE would trigger a bootloop.

Posting this for two reasons:

  1. 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.
  2. 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


  1. Flash the device with Tasmota via UART.
  2. Connect the device to mains power.
  3. Provide WiFi details via Tasmota captive portal.
  4. Connect to the Tasmota web UI and flash a minimal esphome (legacy format) configuration with board set to esp32dev (not nodemcu-32s).
  5. Power cycle the device on mains power, wait a few minutes.
  6. Disconnect mains power.
  7. Flash the device with esphome (modern format) and board set to nodemcu-32s including the WiFi module and SSID / password via UART.
  8. Connect to mains power.
  9. Power cycle the device.
  10. 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:

  1. Compile with ‘esphome run .yaml’
  2. Connect USB Serial device
  3. Hold down the THR320 button, and plug USB Serial device into PC
  4. Upload pre-compiled firmware with ‘esphome upload .yaml’
  5. Release button once upload starts
  6. Disconnect Serial
  7. Wire THR320 into mains power.
  8. Check the logs, with ‘esphome logs .yaml’

I’m currently using a stub config, that looks like this:

  name: tankstat
  friendly_name: TankThermostat

  board: nodemcu-32s

# Enable logging
  level: DEBUG

# Enable Home Assistant API
    key: !secrets apikey


  ssid: !secrets wifissid
  password: !secrets wifipwd

  # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: tankstat
    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.

Hi Guys,

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 :wink:

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?

Thank you!


Yes tasmota works fine!
I though something was wrong afther flashing but just needed configuring afterwards.

Just use

And this template


@Henkonoly Can you share the original THR316 firmware? I flashed mine multiple times with tasmota32.bin, I get only the faint ‘auto led’ issue. I flashed it with the web installer and with esp32 download tool, same result. I can flash it, it can communicate on the UART port, but when it is connected to the main again, it can’t start.

Or anybody has any solution for this faint ‘auto led’ situation???

Update, just to be clear: I’ve tried esp32 download tool with 80MHz then 40MHz settings (previously 80MHz worked on several other ESP32 boards) to upload the tasmota32.bin (downloaded from github), then I’ve used the web installer with tasmota32-bluetooth then plain tasmota (I can’t find plain tasmota32). All results in the pale ‘auto led’ state. When I first turned on this device, I’ve “tested” it, it was able to create a WiFi AP (named Itead something), I considered it OK, then I started the flashing.


The original fw I have wont work for you because its not universal.

But! If you have a faint auto led, your ok.

Just connect to its accespoint en activate the right template.

{“NAME”:“Sonoff THR316”,“GPIO”:[32,0,0,0,0,0,0,0,0,321,0,576,320,0,0,0,0,224,0,0,0,1,0,3840,0,0,0,0,0,0,0,0,0,0,0,0],“FLAG”:0,“BASE”:1}

You can find info Here:

Let me know

Thank you for your reply. I’m an id**t, my first flash attempt was unsuccessful, no AP, I’ve got scared, and later forget to check the AP again… At least my latest web-installer flashing worked, I have a
working AP, Tasmota works on THR316.

I had the very same problem
Glad its fixed :smile: