Page 1 of 1

[DONE/SOLVED] Possibility to record small power consumption ?

Posted: Wednesday 31 August 2022 10:30
by Francis91
Hi,

I'm measuring power with my CurrentCost clamps (one Watt measure every 6 seconds).
I'm using the Dummy hardware with "Electric (instant + counter)", and counter is computed.

With small power (even some tens of Watts), the result in counter is either false (0) or inacurate.

In SQLHelper.cpp, I see this calculation :

float energyDuringInterval = static_cast<float>(powerDuringInterval * intervalSeconds / 3600);
float energyAfterInterval = static_cast<float>(energyUpToInterval + energyDuringInterval);

(for testing purpose, we start at 0, energyUpToInterval = 0)

So, for 20W and 6s : 20*6/3600 = 0.033Wh and for 30W : 30*6/3600 = 0.050Wh

Later, we can see :

sprintf(sValueUpdate, "%s;%.1f", powerUpdate, energyAfterInterval);

Ha ! So, if energyAfterInterval < 0.050, the %.1f brings us back to 0.

The value stored in the dB should be more precise, at least %.3f to avoid such problems.
In the database, sValue is a string (100 char if I recall correctly), so it shouldn't be a problem.

I've compiled Domoticz with this only change, and it perfectly works.
small.png
small.png (48.13 KiB) Viewed 252 times
Thanks !

Re: [done] Possibility to record small power consumption ?

Posted: Thursday 01 September 2022 15:33
by Francis91