Query about kWh from W calculation in emonGLCD

Can someone tell me why the formulea given in emonGLCD for converting W to kWh is given as ...

usekwh += (emontx.power1 * 0.2) / 3600000;

As emonTx seems to transmit data every 5 secs, surely the formulea should be

usekwh += (emontx.power1 / 720) / 1000;

kWh = W * hours / 1000. The above two formulea are not the same thing expressed differently.

I know someone will reply to this and make me look a complete idiot, but I can't see the flaw in my logic.

If power1 is 1 the first gives 5.5555e-8 whereas the second gives 1.38888e-6 which is a HUGE difference, so does power1 hold Watts or is it something else ?

I know I will regret this, but here goes...

Robert Wall's picture

Re: Query about kWh from W calculation in emonGLCD

I've just looked at two emonGLCD sketches and both have the same formula, which is essentially:

Wh += emontx.power1  * ((time - lasttime)/3600000.0);

which, as time is in ms and energy is in Wh (not kWh) looks correct to me.

Your mistake is your basic assumption - the 5 s update. The formula you quote is from a third sketch and it is inside a fast loop that is executed a lot more often than 5 s  -  200 ms in fact.  Does that explain it?

nothing clever's picture

Re: Query about kWh from W calculation in emonGLCD

Yep. Thanks.

It had to be something obvious - I just couldn't see it.

 

Thanks.

Robert Wall's picture

Re: Query about kWh from W calculation in emonGLCD

So although the emonTx updates every 5 s, the loop uses the same value 25 times (every 0.2 s) to increment the kWh reading, then it uses the new value from the emonTx another 25 times. It makes the display change smoothly, but it doesn't improve the accuracy.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.