The bench tested program execution time is alarmingly long: 8 SECONDS!
Does anyone else use this same code? I know by commenting out the two calls
[emon1.calcVI & emon2.calcVI] in the void loop the execution time goes to 0-1 msec.
So each emon instance is using about 4 seconds of processor time to make the
calculations for power factor, real power, apparent power, Vrms, and Irms.
There is a caveat here in that the CT and voltage inputs used to make the calculations are not currently connected. I am still finishing the code & need to mount the processor next to the service panel. This long execution time is not necessarily a problem and I have interfaced through a client/server request with the ESP temporarily hooked up in my computer room. But 4 seconds is a looong time for each instance with what little I know about these processors.
Looking at the lib you posted a link too..
Don't think it's compatible with esp32..
Did find EmonLib-esp32 which is an updated fork..
Also see there's an IDF component emonlib-esp-idf which also mentions being based on the Emonlib-esp32 fork..
Maybe try the esp32 fork..
Which parameters do you pass to the calcVI function? Have you looked at how calcVI works?
The result probably is that the first part of calcVI takes the full timeout that you specified because it can't find the "0 volt". The second part will also not detect the zero-crossings so will eventually time-out.
If you have a board with DAC functionality, I suggest that you let that generate a 3.3V / 50Hz sinewave and test using that.
Have you measured how long an analogRead takes on your board; e.g. time 1000 reads and display the duration / 1000. You can use that number to simulate the calcVI. E.g. if your call to calcVI specifies 100 zero crossings, use a "delay(100 times measured time)".
I suspected something like this. I need to setup a quasi imitation of the service panel here in my computer room (maybe just run one instance of "emon") and see if I get what looks like reasonable data. This is one in a row so their is a huge learning curve with all this. Thanks for the input.