Connect to the Tasmota web UI and flash a minimal esphome (legacy format) configuration with board set to esp32dev (not nodemcu-32s).
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.
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:
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.
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.