Personal AQI Service
As the fire season in California intensifies each year, it becomes increasingly crucial to keep a close eye on air quality. This year, with numerous other challenges at hand, monitoring the air quality around my living space has become more important than ever. To achieve this, I have developed a system that gathers data from PurpleAir sensors, visualizes it using Grafana, and sends alerts when the Air Quality Index (AQI) surpasses 50.
The foundation of this system is PurpleAir’s API, which allows me to fetch sensor data approximately every 5 minutes and store it in a MySQL database. Next, I set up Grafana to create a visually appealing dashboard, complete with a map of sensor locations and other relevant points of interest. Grafana also manages the process of sending push notifications through Pushover.net when the AQI remains above 50 for a duration of 10 minutes.
To facilitate this setup, both MySQL and Grafana are running in containers on my Synology NAS, utilizing external volume storage.
Additionally, I created a Python script that runs on my Intel NUC and is triggered by a CRON job every five minutes. The script performs the following steps:
- Retrieve JSON data from PurpleAir.
- Exclude any sensor that does not fulfill the following criteria:
- Located “outside”
- Reported data within the last 5 minutes
- Positioned within a specific longitude and latitude range
- Convert the raw PM 2.5 value into the US AQI.
- Insert the gathered data into the database.
By implementing this system, I can now effortlessly monitor and stay informed about the air quality around my apartment, ensuring that I can take the necessary precautions during California’s increasingly severe fire seasons.
# MySQL Table
|
|
# Ingestion Script
|
|