Caculation of kWh

hi Everyone!
I am new here, I have searched a lot but can’t found an solution for this:
I am receiving the active power value in Watt throw influxdb and I want to calculate the kWh. I am receving the values every 15s. can someone please help me ?

1 Like

1 Watt for 15 seconds = 15 / 60 / 60 Wh

So, divide Watts by 240 to get Wh.

Divide that further by 1000 to get kWh.

Add them all up (you can of course do the sum() before the division) and
you’ll get your total energy consumption in kWh.

Antony.

2 Likes

thanks for your fast reply,
i have done like this, i think it is correct, can you explaine me what is mean “interval” in query options? and as you can see in the picture I have selected group by time 1h, is this meaning only that the chart will be show hour by hour but the data will be collected every 15 seconds, as configured in influxdb throw node-red? I got this doubt because when i go to “query inspector” and see the data there are showing only hour by hour (see the 2 image)

thank you for your patience.

thanks for your fast reply,
i have done like this, i think it is correct, can you explaine me what is
mean “interval” in query options?

The “interval” is the period of time over which the data is requested from
InfluxDB. It has nothing to do with how often data is put into InfluxDB
(that’s determined by your sampling system), and it has nothing to do with how
often data gets updated in the Grafana display.

So, if you have “interval” set to one hour, you will be getting 14400 values
from InfluxDB, which were sampled every 15 seconds.

and as you can see in the picture

Unfortunately images do not get sent through the email interface of this
forum, so I can’t see the screenshots you have attached, however once you put
any sort of aggregation function into a query (such as “sum”) then you will
indeed get only one value for the time interval you have specified.

Suppose you got samples every 15 minutes instead of every 15 seconds - then
you would have four samples in an hour, and sum() would add them all up to
give a single value for that hour.

Sampling faster means you have more values to add up, but the sum itself is
still just a single number for the hour.

Regards,

Antony.

thank you for your great explanation!
now i am trying to make a bar chart with the daily consumption: I have done like this: SELECT sum(“potenzaAttiva”)/1000/240*24 FROM “table2” WHERE $timeFilter GROUP BY time(24h) fill(null)
But I think it isn’t working ._. can you see any error?