CircuitSetup / Expandable-6-Channel-ESP32-Energy-Meter

Hardware & Software documentation for the CircuitSetup Expandable 6 Channel ESP32 Energy Meter. Works with ESPHome and Home Assistant.
https://circuitsetup.us/product/expandable-6-channel-esp32-energy-meter/
MIT License
538 stars 107 forks source link

esp32 wroom 32d loosing configuration details #175

Open yn1v opened 7 months ago

yn1v commented 7 months ago

I have downloaded the repo and instelled Arduino IDE 1.8 with spiffs upload tool. Downloaded the libraries required and build the firmware. Upload the firmware and data folder to the esp32 and apparently it was working. I was able to calibrate some CT, connect to wifi network and report data to EmonCMS local server.

This setup include one main board plus two expansion board, with 17 CT.

Then after some time it lost connection to wifi network. It becase erratically offering its own AP and desconnecting. I unplugged power and connected to serial monitor. The nodemcu was not coonecting to the wifi and rebooting after some seconds. After some testing found out that waiting for 5 or 10 minutes it stabilize and I able to connect. But it has lost all settings: AP SSID and password; emoncms server, nodename and API key; and also values for CT calibration were reverted to default.

I have tested this with a esp wroom 32u and an external antenna with same results. Changed main board and expansion board. I even tested with a wroom without main board which I did not connect to Emoncms, but lost settings all the same.

I moved to work with platformio and was able to upload firmaware and data spiffs. But at the end have the same result. Al configuration is lost.

I can upload some esphome setup and plain micropython and the nodemcu boots. But i haven´t been able to used the binaries (firmaware and spiffs) on releases section of this repo to make it work with esptool.

sudo esptool --port /dev/ttyUSB0 erase_flash
sudo esptool --port /dev/ttyUSB0 write_flash 0x10000 EmonESP_6_chan_v2.5.7.bin 0x290000 EmonESP_6_chan_spiffs_v2.5.7.bin

I use a serial monitor to see what the nodemcu is doing, and it always ends up with headers errors and not booting. It is like I am missing something like a bootloader or I have wrong the memory addresses.

Other thing that I tried was to use the release file from the repo and do an OTA overwriting de firmware that I have built. Same results.

I am not sure what else I can try to find out what it is happening.

Thanks in advance for any help

yn1v commented 3 weeks ago

How I made it work: Ordered some ESP32 from circuit setup and asked to send the nodeMCU pre-loaded with the firmware.

Further testing that I did was to read flash from the nodeMCU that circuit setup sent and copy the firmware to those esp32 that I have. They booted and worked for some time. In the end they freeze and needed reboot. I meesed up with one nodeMCU from circuit setup, flashed with my copy of the firmware and it is working fine.

Three of those esp32 that I have were flashed with esphome and they have been working just fine.

My conclusions on the whole thing are:

  1. I have some weird Chinese esp32 bought from amazon. Some have external antenna, some have the esp32 offset so the antenna is outside of the nodemcu and some normal looking ones. EmonESP did not worked on those and esphome did.
  2. I have something wrong with my setup as in many occasions I ended up with non-bootable esp32. I am used Fedora 39 Linux on two different computers. I tried using esptool from Fedora repos and from pip.
  3. I wish there is somewhere in the documentation for EmonESP the line to flash the assets from github. That will allow when troubleshooting a test point. Something like: sudo esptool --port /dev/ttyUSB0 write_flash 0x10000 EmonESP_6_chan_v2.5.7.bin 0x290000 EmonESP_6_chan_spiffs_v2.5.7.bin