Hi all,
This thread is a “copy” of an issue I wrote a couple of days ago. Here, it’ll be more visible, maybe other users experienced the same problem.
Playing around with an ESP32-expansion board and ESPHome, I could notice that sometimes, the firmware does not work in a stable way.
It happened mostly after a power-down then power-up.
It looks like, during power-up, sporadically, things are not loaded properly and part of the running environment (RAM, …) is corrupt.
Unfortunately, I cannot describe any clean scenario how to reproduce it.
These problems were combined with some difficulties to get things reset using the web-serial page “Serial Monitor”.
I had to power-down/power-up multiple times until I finally got the correct UI, with all the parameters, like the default Datalog period of 9.80.
During the unstable phase, the serial output was randomly corrupt, sending parameters multiple times, or non-existing parameters or even broken json. For example:
Received data: {"MSG":3085,"V1":232.89,"V2":232.52,"V3":232.80,"P1":1,"P2":0,"P3":0,"P4":0,"P5":0,"P6":0,"E1":0,"E2":0,"E3":0,"E4":0,"E:0,"P6":0,"E1":0,"E2":0,"E3":0,"E4":0,"E5":0,"E6":0,"pulse":0}
I could catch such a line in the log…
Not only are some sensors sent multiple time, but the json is broken too.
"E4":0,"E:0,"P6":0
This part… there’s a missing " AND the tag “E” should be indexed!
The very strange thing is that the json was not always corrupt, these wrong duplicated parameters were not always there, some lines were fully okay!
After I got my Emontx4 fixed, it’s now running perfectly since the 20th of July 13:30 ! I couldn’t find anymore broken lines.
It ran fluently during some time and then…
A couple of minutes ago, I started to see errors and strange things in Home Assistant and on emoncms.org.
Leaving the Emontx4 powered on, I removed the expansion board.
Then I’ve wired only gnd and rx to an FTDI adapter, so that no reboot can be triggered.
Monitoring the serial with VSCode, I see now that instead of getting an output every 9.80 seconds, I get on full line every 0.5 seconds !!
See a piece of output with timestamp:
20:51:11:580 -> {"MSG":51789,"V1":233.03,"V2":233.46,"V3":233.40,"P1":1,"P2":0,"P3":0,"P4":0,"P5":0,"P6":0,"E1":25,"E2":-17,"E3":-20,"E4":2,"E5":-8,"E6":-10,"pulse":0}
20:51:12:049 -> {"MSG":51790,"V1":233.43,"V2":233.72,"V3":233.51,"P1":0,"P2":0,"P3":0,"P4":0,"P5":0,"P6":0,"E1":25,"E2":-17,"E3":-20,"E4":2,"E5":-8,"E6":-10,"pulse":0}
20:51:12:539 -> {"MSG":51791,"V1":233.49,"V2":233.71,"V3":233.31,"P1":0,"P2":0,"P3":0,"P4":0,"P5":0,"P6":0,"E1":25,"E2":-17,"E3":-20,"E4":2,"E5":-8,"E6":-10,"pulse":0}
20:51:13:008 -> {"MSG":51792,"V1":233.47,"V2":233.09,"V3":233.79,"P1":0,"P2":0,"P3":0,"P4":0,"P5":0,"P6":0,"E1":25,"E2":-17,"E3":-20,"E4":2,"E5":-8,"E6":-10,"pulse":0}
20:51:13:497 -> {"MSG":51793,"V1":233.71,"V2":233.38,"V3":233.02,"P1":0,"P2":0,"P3":0,"P4":0,"P5":0,"P6":0,"E1":25,"E2":-17,"E3":-20,"E4":2,"E5":-8,"E6":-10,"pulse":0}
20:51:13:966 -> {"MSG":51794,"V1":233.54,"V2":233.66,"V3":233.71,"P1":0,"P2":0,"P3":0,"P4":0,"P5":0,"P6":0,"E1":25,"E2":-17,"E3":-20,"E4":2,"E5":-8,"E6":-10,"pulse":0}
20:51:14:456 -> {"MSG":51795,"V1":233.32,"V2":233.09,"V3":233.69,"P1":0,"P2":0,"P3":0,"P4":0,"P5":0,"P6":0,"E1":25,"E2":-17,"E3":-20,"E4":2,"E5":-8,"E6":-10,"pulse":0}
The output itself does not seem to be corrupt, so the corruption is due to the esp32 probably because too much data is being sent.
This “timing bug” just happened without any reboot, no power loss, see historical data for MSG in the picture.
At the time I write this thread, my EmonTx4 runs fluently again since the 24th of July 21:17.


