Graphing Electrical Usage from Power Meter

Grafana v7.5.5

I am trying to get some data from influxdb (Working) but I am not able to create sensible graphs of the data and would like some help :slight_smile:

I currently have a sensor setup on my electrical power meter that is measuring flashes of an LED. Every time there is a flash I insert a “1” into influxdb. Every 500 flashes is 1 kwh. I have a table of 0s and 1s.

I can get this data into Grafana no problem, but the graphs it creates just don’t make any sense Im not able to work out how to count this data and output it in a way that gives me the usage for the given time period I select.

Can anyone help please?

Please show us what query you are trying to run on this table of 0s and 1s.

You say “every time there is a flash I insert a 1” and “every 500 flashes is
1kWh”.

When / why / how are you inserting 0s?

I would have thought that either:

select count(flash) where flash=1 and __$timeFilter

or

select sum(flash) where __$timeFilter

would be a good starting point for what you need.

Antony.

If every 500 flashes is 1 kWh, perhaps it is easier to rather insert 1/500 = 0.002 for every flash and timestamp that - or even better every flash is 2 Wh.

Saving it in either 0.002 kWh or 2 Wh makes it easier to aggregate in whichever method you like (e.g. summing per hour, per day, etc).

It also makes it easier to apply a tariff (if this is where you are going) by multiplying the kWh by the rate depending on your tariff rules.

I don’t have experience in influxDb (we use Informix Timeseries) so I can’t help with the query - but I’ve built electricity dashboards for our business so I can help with the theory behind it.

@xbalayer thanks for the info and to be honest I didn’t even think of doing that, as you said it makes it a lot easier. Ive set it to log “2” wh every flash and 0 for everything else.

Which give me the following chart:

Query:

from(bucket: "environmental")
  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)
  |> filter(fn: (r) =>
    r._measurement == "light_status" and
    r._field == "kh"
  )
  |> aggregateWindow(every: 1m, fn: count)

However I’m sure I haven’t got the aggregate part right and I’m a little stuck with this.

What I would like to do is calculate the tariff, but first off id like to just see my usage for the last hour, so should I set the aggregate for 1h? or does setting the time period in grafana give me the usage for that time period selected?

Thanks for any help!

Unfortunately I’m not familiar with InfluxDB, hopefully someone else can help you (@pooh ?)

But, looking at their documentation I would guess that should be:

aggregateWindow(every: 1h, fn: sum)

Sorry, I do InfluxQL for InfluxDB v 1.8, not Flux for InfluxDB v 2.0 :slight_smile:

Antony.

This topic was automatically closed after 365 days. New replies are no longer allowed.