Home / Companies / Sanity / Blog / Post Details
Content Deep Dive

Lab Notes: Setting up air quality notifications with Purple Air, Sanity, Vercel, and Twilio

Blog post from Sanity

Post Details
Company
Date Published
Author
Even Westvang
Word Count
2,918
Language
English
Hacker News Points
-
Summary

Amidst the challenges of living in the Bay Area during a pandemic and rampant wildfires, an individual devised a system to monitor air quality using the Purple Air Sensor Network. This network utilizes cost-effective sensors to measure particulate matter in the atmosphere, providing real-time data essential for assessing air quality, particularly during such environmental crises. The individual, seeking a simple solution, utilized Sanity.io for data storage and Twilio for SMS notifications, enabling alerts when air quality deteriorates to unsafe levels. Despite limited coding experience, they implemented a system using JavaScript on Vercel, overcoming hurdles in setting up Python and choosing to port libraries to JavaScript. Air quality data fetched from Purple Air is converted to Air Quality Index (AQI) values, though adjustments were necessary to account for inaccuracies in low-cost sensors, particularly with wood smoke. Notifications are sent via SMS to alert when air quality crosses certain thresholds, with measures in place to prevent spam by limiting message frequency. The project also explores adding visual data representations via Quickchart and considers further enhancements like error handling and averaging sensor data.