Today’s adventures in DIY IoT air quality monitoring
This weekend I reworked a few things that needed to get done
Lots of gaps in the data while I was working on this 😅
Debugging
nginx lets me add HTTP endpoints for the health of the app, or to early fail certain URLs (favicon and such)
Visualization
I also wanted to improve the graphs, and there isn’t much to say except I dug into the docs for the lib, and now
- absent data shows a gap
- less lines to connect dots that don’t need connecting
SQLite
I hate to admit that I had to remove a CTE that looked impressive in the SQL, but was wrong and exacerbated data duplication (which I also had to address)
HTTP round-trip time
I was annoyed that the ESP32 needed a steady 225s every time it wanted to upload sensor data coming from the mesh, which is once per 3s times 6 sensors, so it was spending half the time doing that
That led, I believe, to mesh instability and required a reboot of each node, so it needed fixing
So I had a plan:
- switch the web server (php -S) for a php-fom & nginx combo
- reuse the TCP connection
I did not expect the change in server stack to have so little effect, I thought opcache at least would lead to measurable improvement; it didn’t (not more than 10%)
I also hoped that reusing the TCP connection would lead to more stable network; quite the contrary!
Overall, the fastest uploads are now less than 70ms, so that’s an improvement by 2/3rd
But… While my previous program was either succeeding in 220ms or waiting indefinitely, the current one can do a successful round trip in either 70ms, or 125 ms or 330 ms, or anything in-between 🤷♀️
Regardless, I’m happy with the new setup. I know that I was unable to add more nodes with the previous program, however, the current iteration can reuse TCP more efficiently the more often there is stuff to upload, so there is room to grow
https://github.com/GuillaumeRossolini/griotte
#arduino #sqlite #DiyAirQualityMonitor #DiyAirQualitySensor #mesh