Get alerts when your nearest PurpleAir sensors reach a certain air quality index (AQI) threshold.
- Setup access to the PurpleAir and Gmail APIs.
- Replace
API_KEY
with your PurpleAir API key. - Replace
LAT_LONG_BOUNDS
with a 4-tuple that consists of: (north west longitude, north west latitude, south east longitude, and south east latitude). These will bound the geographic area where sensor data will be taken from. - Replace
TO_EMAIL
andFROM_EMAIL
fields with your desired email addresses. - Run the script. (The first time you run it, you'll need to go through an auth flow with Gmail)
- In order to run this continuously, you will need to hook this up to an external service.
- Connects to PurpleAir API and grabs relevant sensors based on user-input longitude/latitude bounds.
- Modifies PM2.5 values received from these sensors with a USA EPA conversion formula.
- Converts these values to AQI values.
- Determines which sensors show AQI values > 50.
- Send an email about these sensors via the Gmail API.
- PurpleAir API
- Gmail API
- Libraries listed in dependencies.txt