openshwprojects / OpenBK7231T_App

Open source firmware (Tasmota/Esphome replacement) for BK7231T, BK7231N, BL2028N, T34, XR809, W800/W801, W600/W601, BL602 and LN882H
https://openbekeniot.github.io/webapp/devicesList.html
1.47k stars 274 forks source link

Incorrect calculations for BL0937 power meter pulses #1270

Open rpv-tomsk opened 5 months ago

rpv-tomsk commented 5 months ago

https://github.com/openshwprojects/OpenBK7231T_App/blob/59fcf19bbdee45dee56f23e74ac3b8e1cacca5da/src/driver/drv_bl0937.c#L354-L361

I'm sorry if I'm wrong, but for me this code looks incorrect. If we count more pulses due to more ticksElapsed since previous counter reset, the measured value (Voltage,Current, Power) should be less, not greater. Division and multiplication are swapped here.

giedriuslt commented 4 months ago

Could this incorrect calculation cause wrong values with powersave? I need to try