Emontx3 and wifi esp8266

I think this should be sending data. It also send all the “Hello…” stuff (version, calibration settings etc associated with the Serial.print(...) statements in setup( ), but you ignore those.

I’m not very familiar with the ESP8266, and I haven’t found time to get mine working again yet, so there’s not a lot I can do with that end. However, that might be OK. I can’t remember the baud rate the ESP8266 expects, I’ve a feeling it’s not 9600, so this should be changed in the sketch (line 126) to suit the ESP. This wrong will happily stop all sensible output.

What I’ve done is forced debug = 0 immediately below line 198 to get rid of some of the unwanted human user config messages and output

  if (Serial) debug = 1; else debug=0;    //if serial UART to USB is connected show debug O/P. If not then disable serial
debug=0; 

but your main problem was it was going to sleep before it had chance to send all the wanted serial data. I cured this by putting a big delay - probably too big - just after that at what is now line 378

    if (CT4) { Serial.print(F(",power4:")); Serial.print(emontx.power4); }
    Serial.print(F(",Vrms:")); Serial.print(emontx.Vrms*0.01);
    Serial.println("");
delay(100);

You also need to increment the message count:
Serial.print(F("MSG:")); Serial.print(emontx.Msg++);

[The significance of putting these bits right over to the left is so that they stand out!]

You’ll will need to shorten the main delay to keep the reports coming at just under 10 s intervals - it’s a little over at present. But if data gets cut off, lengthen the 100 ms delay and shorten the main one even more.

[I had my Covid booster today, and I feel bloody awful. So if I don’t respond tomorrow, you know why.]

Bingo, what a beaut you are Robert Wall, I have data coming out my ears.
Thank you so much.
I shall now try and understand the small changes you make that make so much difference like the 100 after delay and ++after emontx.msg

1 Like

“100” is the delay in ms. What happens is the serial output doesn’t happen immediately, control returns to the sketch while it’s still sending the output. But the next line puts the processor to sleep - so only the first part of the output got sent. If serial output is garbled or cut off, it’s a reasonable bet that you need a delay to allow it to complete.

“++” is a postfix operator, it increments emontx.Msg after it’s been printed. If you wanted it to display 1 for the first message, you would use the prefix operator and write ++emontx.Msg. You can do the same with -- to decrement the variable.