Query to calculate energy (kWh)

I just migrated over to influx from SQLite and I’m having a hell of a time building a query to calculate the energy used by my battery.

I feel like the query should be:

image

Dividing by 3600 because I want the last hour.

But I also feel like that’s since there’s no way I’ve only used 588Wh.

1 Like

Here’s some sample data

Killowatts are normally delivered as a rate - meaning that they are usually in the form of killowatt hours.

Assuming that the measurements are kw/h, you’re more likely to want…

SELECT avg(kWatts) FROM Status WHERE time > now() - 1h

This should give you something like 2.7 kilowatts per hour. If 2.7 is an instantanious measurement, you’re consuming truly incredible amounts of power (and it doesn’t make a great deal of sense given your voltage and current - unless I’m not understanding your raw data).