Query series of data with 30 minute intervals

Hi! I am new to influxDB, and wonder if what I want to do, is possible in InfluxDB, hope this is the right place:

I have a few sensors logging temperature data into an influxdb. They do that at irregular intervals, meaning not on specific timestamps or intervals, but if enough of a temperature change was detected.

What I am trying to do is calculating degreedays from those sensors:

  • at midnight, select 48 temperatures from the past day, with 30 minutes in between.
  • add up those 48 samples, divide by 48 and store that result as a separate value back into the db
  • repeat every day
  • once: do it for all the data already present in the db.

The problem is that those sensors cannot report specifically on those timestamps, so I am trying to find a way to get the temperature that was logged last before a desired timestamp.

For example: at 9:25am a sensor reports 20C. At the end of the day, I want to know the temperatures at 30 minute intervals, so 9:30am. There is no exact report at that time, so the last known is 9:25.

To be honest: I have no idea where to start. I manage to get a series of data out of influxdb as a straight select query, but no clue how to get this going? Anybody able and willing to help?

Hello @arno,

Yes this is totally possible with Influx.
I would recommend using the LAST() function in conjunction with a CQ to store the queried results in a new db.

1 Like

Thank you @Anaisdg! I ended up calculating the average in Node Red for practical reasons, but I did not know about CQ’s before, which opened up a whole new list of possibilities, thanks!

1 Like