## Calculating kWh from Amps+Volts

**Moderators:** grovkillen, Stuntteam, TD-er

### Calculating kWh from Amps+Volts

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

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

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.

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.

- grovkillen
- Core team member
**Posts:**3621**Joined:**19 Jan 2017, 12:56**Location:**Hudiksvall, Sweden-
**Contact:**

### Re: Calculating kWh from Amps+Volts

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.ESP Easy Flasher [flash tool and wifi setup at flash time]

ESP Easy Webdumper [easy screendumping of your units]

ESP Easy Netscan [find units]

Official shop: https://firstbyte.shop/

ESP Easy Webdumper [easy screendumping of your units]

ESP Easy Netscan [find units]

Official shop: https://firstbyte.shop/

**Sponsor ESP Easy, we need you**### Re: Calculating kWh from Amps+Volts

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

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

- you could move the db to a ramdisk

- node-red is also an option

- node-red is also an option

### Re: Calculating kWh from Amps+Volts

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

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

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.

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.

- grovkillen
- Core team member
**Posts:**3621**Joined:**19 Jan 2017, 12:56**Location:**Hudiksvall, Sweden-
**Contact:**

### Re: Calculating kWh from Amps+Volts

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

ESP Easy Flasher [flash tool and wifi setup at flash time]

ESP Easy Webdumper [easy screendumping of your units]

ESP Easy Netscan [find units]

Official shop: https://firstbyte.shop/

ESP Easy Webdumper [easy screendumping of your units]

ESP Easy Netscan [find units]

Official shop: https://firstbyte.shop/

**Sponsor ESP Easy, we need you**### Re: Calculating kWh from Amps+Volts

@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.

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

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.

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

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

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

### Who is online

Users browsing this forum: No registered users and 17 guests