Page 1 of 1

Calculating kWh from Amps+Volts

Posted: 11 Dec 2018, 15:19
by mitrus
Hallo

I have INA219 current measurement device connected to ESP Easy and I'm able to read current.
Circuit works in 12V, currents are between 0A and 1A.
Im able to sent current current value each 60s to my database.
Is it possible that ESP Easy will measure current in each cycle and sum this to power consumption presented in Wh(kWh) and then send to database?
What formula I should use?

thanks
Peter

Re: Calculating kWh from Amps+Volts

Posted: 11 Dec 2018, 15:50
by xury
I don't think so.

To compute kWh from recent instantaneous power you have to calculate derivative.
What a database you use?
I had influxdb with grafana and is possible with it. But you have to set a server machine.
grafana.jpg
grafana.jpg (165.26 KiB) Viewed 4456 times

Re: Calculating kWh from Amps+Volts

Posted: 11 Dec 2018, 16:28
by grovkillen
But momentary usage in W is better to display, I only plot W. And as @xury is saying, you need to derive W over time for the Wh.

Re: Calculating kWh from Amps+Volts

Posted: 11 Dec 2018, 17:21
by mitrus
The problem is that consumption can take only 30 sec i.e. or sometimes 30min I'm using NETTEMP project. And to have nice plot and calculate this later it would be good to have 1s interval and I'm afraid this frequency will kill my SD card in RPi that's why I want that esp will sum this and then send value to db exactly how it works with counters.

I presented only example because oryginal idea is to measure current used for coil modulation in gas heater and then try to calculate gas usage.

P.s. Ładny domoticz. Też się zastanawiam nad przejściem ale Nettemp już znam do podszewki 😂

Re: Calculating kWh from Amps+Volts

Posted: 11 Dec 2018, 17:54
by moebius
- you could move the db to a ramdisk
- node-red is also an option

Re: Calculating kWh from Amps+Volts

Posted: 11 Dec 2018, 21:33
by xury
So you have to feature request Nettemp developers for derive and difference functions over time.
Tu calculate kWh need stored all momentary values over the time. Espeasy doses not have a storing database, so calculate derivative is not possible without stored data. Data store is not possible without database. Closed circle.

PS. To nie Domoticz to Grafana. Z Domoticza są tylko pobierane dane.
Pozdrawiam krajana :)

Re: Calculating kWh from Amps+Volts

Posted: 11 Dec 2018, 22:34
by kimot
I think only solution with ESPeasy is set TImer to 5 or 10s interval.
If Timer triggers, measure current, calculate Watts and then you have got energy in "W10s".
Sum this 6 times and got Wmin.
Then send to Domoticz.
But you must do lot off calibration, because 10s timer is not exactly 10s and each interval is
a little different.

Re: Calculating kWh from Amps+Volts

Posted: 12 Dec 2018, 06:13
by grovkillen
Of course a external EEPROM module might be the way to go, but that is not yet implement and after that a generic way of aggregating data over time is needed. We're still trying to release a first stable release and aim for this year ;)

Re: Calculating kWh from Amps+Volts

Posted: 12 Dec 2018, 12:17
by mitrus
@grovkillen it's good to know that project is working around this.
Thanks to all for ideas, propably my solution will be this time own application for ESP where I'll read 60 times current value and process this to kwh then sond once minute portion to database. My question wa only that maybe this kind of alghoritm can be implemented already in Esp Easy by some addons. scripts etc.

Re: Calculating kWh from Amps+Volts

Posted: 17 May 2019, 07:40
by StefanD
Hi,
And sorry for delay in answering...
If you look at the datasheet of INA 219 you will see that in the registers it is available also power calculation not only current and voltage. In order to display power in Espeasy the plugin must be modified and this is quite simple...
Best regards
Stefan D.

Re: Calculating kWh from Amps+Volts

Posted: 17 May 2019, 13:03
by rayE
I use SonOff POW so the instantaneous power is already calculated. This is how i calculate kwh...........

1. Take power reading every 5S and store in a dummy var (accumulator)
2. On the next sample add to the dummy var (accumulator).
3. After 6 samples divide the dummy var by the number of samples.
4. Send this to ThingSpeak every 30 seconds.

At the thing speak end i set up the kwh graph to average the present hours readings. With proper calibration im getting around +/- 2.5% accuracy compared to the sites main electric meter.

See here for my real time power monitoring.

https://thingspeak.com/channels/763964


Ray