Pico Enviro & InfluxDB: Time of insertion is displayed on grafana instead of time of recording

I recently followed a very helpful tutorial to set up my Pico Enviro Grow kit. I can know read data and store it on an InfluxDB running on another rpi. I never used InfluxDB before and am exploring its capabilities. It works very well with grafana. However, I have one challenge. My pico collects data every 15 minutes and transfers the data to influxdb every 10 readings. So by the time the the data is transferred there are multiple readings. When this data is inserted to influx, however, all readings (e.f. Temperature recorded 10 times at 15 min intervals) seem to share the same timestamp, which is the time of insertion. I only followed the provisioning of Enviro Grow and choose InfluxDB. Is there a way to reflect the timestamps of actual recordings instead of the time of insertion?

Here is the tutorial I followed: Enviro (Pico W Aboard) and InfluxDB

I think this bug’s been fixed but it’s not made it into a release yet - if you find the line in your enviro/destinations/influxdb.py that says:

payload += f"{key},device={nickname} value={value}"

and change it to

payload += f"{key},device={nickname} value={value} {timestamp}"

then the timestamps should behave themselves.

1 Like

This solves it, perfect. Many thanks!

1 Like

Do you know if there’s a similar fix for a setup where you’re sending through MQTT, processing in Node-Red before inputting in a locally-hosted InfluxDB database?

I have the same problem with the timestamp being time of injection, but haven’t found an easy fix yet. There’s some talk about adding some node-red function code but haven’t been able to work it out.

EDIT: Solved it… updated the .uf2 file on the pico to enable influxDB transfer on the enviro board, and then activated direct InfluxDB destination which now includes the fix mentioned above.