How Hot Is It In My Apartment? 3
Over the summer of 2023, I embarked on a journey to “upgrade” my apartment’s climate monitoring system…mostly inspired by trips to Micro Center where I got a hold of a few ESP32s. Let me explain.
Previously, the climate monitoring system in my apartment (How Hot 2) was a Raspberry Pi in the living room with a load of sensors, and another Pi in the bedroom with a SHTC3 temp/humidity sensor.
How Hot 3 changed the entire system to use ESP32 boards from Adafruit (2x Qt Py ESP32-S2 for the living room/bedroom, and a Feather ESP32-S2 w/ BME280 for the office) running on CircuitPython, upload data to InfluxDB 2, and display this data on a Grafana dashboard, while also being backwards compatible with How Hot 2 (and the website online).
How Hot 3 is just as resilient as How Hot 2 - all while freeing Raspberry Pis for other projects, providing an extra data point in my office, and making the most of Grafana by tapping into its alerting system.
—
Timeframe: April 2023 - August 2023
This is the main dashboard of How Hot 3 in Grafana. From here, I can get a pulse on all the key metrics across the apartment, in addition to looking at 6 hours of historical data of temperature & humidity from all rooms.
The gauges and charts are colored based on thresholds from How Hot 2.
Additionally, each room has its own Grafana panel, as shown here. This is the panel for the Living Room.
The individual panel is what powers the alerting system, you can see that from the heart icons above the two graphs on the page.
A quick example of some of the Slack alerts that come from Grafana.
Each room has alerts for when the temperature, dew point, and humidity pass certain thresholds. For temperature, I’ll get a slack notification if any room goes above 90 degrees, or below 60 degrees. Humidity has thresholds of 15% and 70%, dew point similarly has thresholds at pretty damp or dry points.
I haven’t messed with changing the alert title/description past the defaults that Grafana uses, but that’s something I may do in the future.
Here’s the hardware setup for the Qt Py ESP32 in the living room. You can see the headers attached to a Stemma QT connector on the SHTC3 temperature sensor, then chained to the DPS310 pressure sensor and the PMSA003I air quality sensor.
Hardware setup in the bedroom is as follows. It’s another Qt Py ESP32-S2 with a SHTC3 attached to it on a single Stemma QT jumper wire.
And lastly, the Feather ESP32-S2 with a BME280 onboard, lovingly taped a few feet above my desk.
This board is actually what inspired the current ESP32 operating method. This specific Feathre board influences the onboard BME280 and increase temperature readings by ~12-14 degrees if it stays on all the time.
To get accurate readings, I had to switch to a sleep then wake method every 5 minutes, with each board sending its sensor readings to HH2/Influx. The system use to be the other way around - each board in each room had an always on HTTP server, and every 5 minutes a Python script hit each rooms server to get readings.
Ultimately, the sleep and wake method turned out to be a lot more reliable especially on the ESP32s. While a Pi can run Apache rock-solid, I ran into issues with the HTTP server libraries available for CircuitPython, with the boards eventually failing with a code issue after a few days and requiring a reboot manually.
(note - on the office ESP32, sensor data is read before a Wi-Fi connection is established to ensure data accuracy.)
Here’s a flowchart describing the current code flow of the ESP32s. Everything should be pretty self explanatory. InfluxDB is hosted locally, the HH2 API is sitting on my web VPS. Reference data is for the delta to outside comparisons on the website, which only the living room takes care of (as it’s the only sensor on the HH2 site)
You may be wondering what that timestamp server is, and I’m glad to provide an answer. The ESP32 does not have a battery RTC (especially the Qt Py ones), nor does it sync with NTP when you connect to Wi-Fi (I may research ways to do this). However, the boards need to know what time it is to know how long to sleep for!
To figure this out, I added a method to the OctoCam Backend (which runs on my apartment network) that simply returns the current timestamp as text. Is it as accurate as NTP? Not at all. But it’s good enough for second-level precision to know just about when to wake the board up again in 5 minutes minus execution time.
And that’s How Hot 3! It’s been an extremely fun experiment/project to discover the ESP32 series of boards and I’m super happy I took the plunge. Especially for single-purpose, low-compute projects like this one (where throwing a Pi at it is overkill), these things are perfect for the job.