Temperature is
knowledge! Now that we have the values
read via Python as seen in the previous installment - https://astromaphilli14.blogspot.com/2021/08/building-dual-temperature-sensor-on.html
we're now able to consider storing these values for logging and trending. You'll want to consider a proper database to house all your temp and humidy values. InfluxDB is an awesome opensource package, so that is what I used.
Thanks to one of my coworkers for showing me the ropes of database and sql queries! The secret sauce is reusing the python script that reads the temp values to simply write as they're read. The following edits to the python code allow us to InfluxDB for use in Grafana! GO NERDS!!!!
Overly simplified you simply write the data that you want:
from influxdb import InfluxDBClient
# defines DB resource
client = InfluxDBClient("www.sm.sm", 8086, "grafana", "YOURSECRET", "astrocarttemp")
client.create_database('astrocarttemp')
client.write_points(json_AirTemp)
client.write_points(json_MirrorTemp)
client.write_points(json_AirHumidity)
client.write_points(json_MirrorHumidity)
client.write_points(json_DeltaT)
The scripts are all in my github pages - https://github.com/maphilli14/RPiTempSensorGrafanaLogger/commits/main
The logic is somewhat simple:
- Read air and mirror sensors and parse out the temperature and humidity values
- Assign values to JSON data
- Write to InfluxDB
- Graph in Grafana
- Optionally I pull OpenWeather to compare to my own air measurements, helpful when scope is indoors!
There are a lot of steps to take that data written in InfluxDB to open them up and setup in Grafana, but there's plenty of guides to help you with that.
SELECT mean("value") FROM "AirTemp" WHERE $timeFilter GROUP BY time($__interval) fill(null)
SELECT mean("value") FROM "MirrorTemp", "AirTemp" WHERE $timeFilter GROUP BY time($__interval) fill(null)
SELECT mean("value") FROM "MirrorTemp", "AirTemp", "MirrorHumidity", "AirHumidity", "DeltaT" WHERE $timeFilter GROUP BY time($__interval) fill(null)
This seems like lots of work but that graphs used in the Why do you need blog are used to help illustrate the need for temperature control and considerations.
My current influxDB setup looks like this in grafana!
This view shows you the realtime, averaged and trending temps / humidity for both air and mirrors as well as the openweather temp and humidity!
This is a historical live view of the cooling running on the scope while it was outside at night!
No comments:
Post a Comment
You are no longer able to spam this blog
Note: Only a member of this blog may post a comment.