ESP32 not recognised after programming

Apologies for asking what might be a simple question, but I’m new to coding and to Home Assistant. I have spent several days trying to sort this out, but without success.

I am trying to set up a couple of esp32 modules to read multiple DHT11 temperature/humidity and access the readings via Home Assistant.

I have followed the Home Assistant and Youtube videos to prepare the esp32 for first use. I initiated the chips using Arduino IDE software. I was unable to do this via the ESPHome add-on in Home Assistant due to errors - (sorry, can’t remember exactly what - Ive spent 5days looking at various error messages!), but I managed to install the flash ‘for first use’ using website. This worked perfectly, and the esp32 ‘nodes’ (think that’s the right term) appeared on the espHome page of Home Assistant and I was able to adopt them. However, if I edited any code and re-flashed through Home Assistant espHome, I kept getting library file errors (corrupt JSON file). I even tried flashing the original code without any modification via espHome in Home assistant and that failed too. Every time leading to the the nodes being permanmently offline in Home Assistant (even though I could access them via their IP number or via the webpage. I tried uninstalling and reinstalling the the esp32 add-on to Home Assistant. I have tried saving the code (even the original unaltered code from the first-time-flash) and flashing it with - which uploaded without any errors at all, but then the nodes would stubbornly stay off-line in Home Assistant ESPhome page, even though they were clearly connected and registered with Home Assistant. I’ve found various threads on the Home Assistant Community where people have experienced similar error messages, and tried to follow their solutions, but without success. I upgraded my Home Assistant add-on from ESPHome to ESPHome (beta) and that now allows me to flash the esp32 directly from ESPHome on Home Assistant - which I couldn’t do before…but frustratingly, once I’ve done so, the esp32 goes offline and is not discovered by Home Assistant (even where I am re-flashing the original code without any alterations).

I think I must have had some kind of corruption in the original EspHome add-on, but even now it is still not working - maybe I should not have initiated the chips with the ESPHome(beta) instead of using Maybe I shouldn’t have initially tried with Arduino IDE? Maybe I need to erase the esp32 somehow (I don’t know how) and start from scratch using Home Assistant and the espHome(beta) page?

Any suggestions?

Sorry my bad English, will describe my way for new devices.

Preparing YAML file for device in ESPHome Dashobard on HA server - good editor which guide on errors, show mandatory options, etc.

Then copy file(s) (files when using packages etc., but new devices usually initialize with minimal config, actually wifi/ota/api only required just to connect to HA) to ESPHome installation on Windows PC, where ESPHome installed too.

Next step - connect ESP board to USB port (most of modern board does not require pressing keys, connectins pins etc. to enter flash mode), run command ‘esphome run xxx.yaml’ and after it compiled simply choose serial port to upload firmware to device.

That’s actually all - device reloads, connects to WiFi and just need to add it as HA device.
Now can edit YAML file on HA ESPHome Dashboard and upload new versions.

If board have CP2102 port - can connect directly to HA server USB port.
Last time tried - CH340 was not yet supported by HA.

Please let us know what ESP32 boards you are using as some require additional parameters for flashing.

For example some ESP32-C3 boards require the following platformio_options to be set:

    board_build.flash_mode: dio

Thankyou for your reply!

I’ve just noticed that the wifi details in ‘secrets’ yaml was duplicated, so I have deleted the duplicate. That seems to have helped. Let’s see if I can get them programmed…

Im using the nodeMCU esp32 board. I’ve been using the esp32dev board type for the programming. It seems to work ok - just home assistant that is struggling,

If the device is online but not showing as online in the esphome ui, try setting “Use ping for status” in esphome addon settings.

Thankyou. It seems that the duplicated wifi username/password which it had generated in ‘secrets.yaml’ was messing things up. Seems to be very reliable since I un-duplicated it!

1 Like