EmonLib.h with ESP8266

Good afternoon.
I plan to use ESP8266 to measure AC voltage 220V.
To do this, I try to use the ZMPT101B module, the EmonLib master library (EmonLib.h), and the Voltage.ino (reading ac voltage by zmpt101B - Programming Questions - Arduino Forum) sketch.
When there is a voltage at the module input, the sketch outputs values ​​to the terminal.
But as soon as the voltage disappears at the module input, an error appears:

ets Jan 8 2013, rst cause: 2, boot mode: (3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ ld
⸮0.00 0.00 217.27 0.00 nan
0.00 0.00 172.59 0.00 nan

Soft WDT reset

ctx: cont
sp: 3ffef1f0 end: 3ffef4b0 offset: 01b0

stack >>>
3ffef3a0: 4021a51d 00000004 00000000 4112e264
3ffef3b0: 4021a7bf 00000004 00000000 3ffee2d8
3ffef3c0: 000007d0 00000004 00000000 00000000
3ffef3d0: 40213a20 00000000 00000000 3ffee2d8
3ffef3e0: 05fb05fb 05fb05f9 05fb05f9 05fb05fb
3ffef3f0: 00000000 000002fd 40204064 000012a1
3ffef400: 40201126 7ff80000 feefeffe 3ffee484
3ffef410: 40101afc 001622e3 000012a1 40201e79
3ffef420: 40101afc 00169d0d 3ffee3ac 00000000
3ffef430: 3ffe8910 00000014 00000000 4087e800
3ffef440: 3ffe835c 3ffee2c8 402028c4 3ffee490
3ffef450: 402010ae 00000064 00000064 3ffee484
3ffef460: 3fffdad0 00000000 3ffee2d8 40201cd8
3ffef470: feefeffe feefeffe feefeffe 3ffee484
3ffef480: 00000000 00000000 00000001 3ffee484
3ffef490: 3fffdad0 00000000 3ffee47c 40202910
3ffef4a0: feefeffe feefeffe 3ffee490 40100114
<<< stack <<<

I ask to help to solve the problem.
Thank you.

I do not know about the ESP8266.

The emonLib function that reads the voltage calcVI( ) MUST have a voltage input to work, because it needs to count the number of half-cycles at mains frequency (60 Hz for you? ).

If it does not have a voltage, it waits for 2 s, then it tries again.

The timeout for calcVI( ) is set to 2000 ms (= 2 s) here:
emon1.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out

If your watchdog timer is set to less than 2 s, then your watchdog will reset. I think that is what “Soft WDT reset” means.

First, make your watchdog timer longer. We use 8 s.
If that does not work, reduce the calcVI( ) timeout to 400 (= 24 mains cycles).

1 Like

Thank You very mutch, Robert.
You very helped me.
I reduce timeout and all is working ok.
Thank You!

Thanks Robert :slight_smile:

I changed this :
emon1.calcVI(20,2000);

To this :
emon1.calcVI(20,500);

And it solved this issue

1 Like