personal-site/content/Sensors.md

66 lines
2.8 KiB
Markdown
Raw Normal View History

2022-05-24 21:37:06 +00:00
Title: Sensors
Date: 2022-05-24
Category: Notes
2023-04-18 21:20:52 +00:00
Summary: Graphs of various sensors around my house.
2022-05-24 21:37:06 +00:00
Short: d
2023-04-20 00:39:45 +00:00
## 24h Graphs
2023-04-18 21:20:52 +00:00
2023-04-20 00:39:45 +00:00
These graphs are live and generated every 10 minutes, assuming the script works:
2023-04-18 21:20:52 +00:00
![a graph](https://sensor-pics.dns.t0.vc/Solar_Power.png)
Black: power (W), green: energy (kWh)
![a graph](https://sensor-pics.dns.t0.vc/Living_Room_Air.png)
2023-04-18 21:23:50 +00:00
Black: PM10 (ug/m³), red: PM2.5 (ug/m³), blue: CO₂ (ppm), green: VOC
2023-04-18 21:20:52 +00:00
![a graph](https://sensor-pics.dns.t0.vc/Outside_Temperature.png)
Black: temperature (°C)
![a graph](https://sensor-pics.dns.t0.vc/Bedroom_Temperature.png)
2023-04-18 21:23:50 +00:00
Black: temperature (°C), blue: humidity (%)
2023-04-18 21:20:52 +00:00
![a graph](https://sensor-pics.dns.t0.vc/Nook_Temperature.png)
2023-04-18 21:23:50 +00:00
Black: temperature (°C), blue: humidity (%)
2023-04-18 21:20:52 +00:00
![a graph](https://sensor-pics.dns.t0.vc/Misc_Temperature.png)
2023-04-18 21:23:50 +00:00
Black: temperature (°C), blue: humidity (%)
2023-04-18 21:20:52 +00:00
![a graph](https://sensor-pics.dns.t0.vc/Nook_Thermostat.png)
2023-04-18 21:23:50 +00:00
Black: temperature (°C), red: setpoint (°C), green: state (off / running)
2023-04-18 21:20:52 +00:00
![a graph](https://sensor-pics.dns.t0.vc/Gas_Usage.png)
Black: total (MJ), green: delta (MJ)
![a graph](https://sensor-pics.dns.t0.vc/Water_Usage.png)
Black: total (L), green: delta (L)
![a graph](https://sensor-pics.dns.t0.vc/Living_Room_Lux.png)
Black: light (lx)
## Live Dashboard
A live interactive version can be found on this [dashboard](https://sensors.dns.t0.vc/).
2022-05-24 21:37:06 +00:00
You can find the [source code](https://git.tannercollin.com/tanner/sensors) on my Gitea.
2023-04-18 21:20:52 +00:00
## Data Capture
2022-05-24 21:37:06 +00:00
Most of the data is captured by two cheap RTL-SDRs (software-defined radios) that are set to listen to 433 MHz and 915 MHz radio frequencies. I use the open-source project [rtl_433](https://github.com/merbanan/rtl_433) to automatically decode the signals and forward them to an MQTT broker, which is a messaging server that services can publish and subscribe to. Other sensors run an MQTT client directly or expose their data through other means like a web interface that I poll.
The data gets collected by a central Python script that process and stores it in an InfluxDB database for "efficient" storage. The script also runs a web server that queries the database and exposes the data over an API to the dashboard at various dates and ranges. The dashboard is written in JavaScript / React using a simple chart library.
2023-04-15 04:06:26 +00:00
My biggest regret was using InfluxDB. It's a stupid database and I wouldn't recommend it to anyone. The documentation is confusing and I ran into timezone issues with `group by time()`. It also assumes the column data type is an integer if your sensor happens to send it a whole number at first and it won't let you change that. Their docs are bad. They dropped the SQL-like InfluxQL syntax for querying with a pipeline-like syntax called Flux in version 2.0. Debian's repos seem to be staying with version 1.x though.
Just stick to Postgres / SQLite.