Air Quality Sensors

Air Quality Sensors (Monitoring & Environmental Projects)​


Air quality has become a major concern in recent years, with rising pollution, wildfire smoke, and indoor contaminants affecting health. The Raspberry Pi is an excellent platform for building DIY air quality monitoring systems, both for personal use and for larger community-driven environmental projects. With the right sensors, the Pi can measure particulate matter, gases, temperature, humidity, and more — turning data into actionable insights.




1. Why Use Raspberry Pi for Air Quality Monitoring?​


  • Affordable: Commercial air monitors can cost hundreds of dollars. A Pi + sensor costs a fraction of that.
  • Customizable: You decide what to measure — PM2.5, CO2, VOCs, humidity, etc.
  • Scalable: Deploy one Pi for your bedroom or dozens across a city for a community project.
  • Networked: Data can be logged locally, sent to the cloud, or displayed on dashboards.
  • Educational: Perfect STEM project to teach coding, electronics, and environmental science.



2. Common Air Quality Sensors for Raspberry Pi​


Particulate Matter (Dust & Smoke):


  • PMS5003 / PMS7003 – Measures PM1.0, PM2.5, PM10 particles (dust, smoke, pollution).
  • SDS011 – Reliable PM2.5 sensor, widely used in citizen science networks.

Gas Sensors:


  • MQ Series (MQ-2, MQ-7, MQ-135) – Detect gases like CO, CO2, methane, or alcohol.
  • CCS811 – Measures VOCs (Volatile Organic Compounds) and estimates CO2 levels.
  • MH-Z19B – Dedicated CO2 sensor with good accuracy.

Environmental Sensors:


  • BME280 / BME680 – Measure temperature, humidity, pressure, and VOCs (BME680 adds gas sensing).
  • DHT22 – Simple temperature/humidity sensor, often paired with air quality builds.



3. How to Connect Air Quality Sensors​


Most air quality sensors use UART, I2C, or SPI communication protocols. The Raspberry Pi supports all of these via GPIO pins.


  • I2C: Common for BME280, CCS811. Easy to chain multiple sensors.
  • UART (Serial): Used by PMS5003 or SDS011.
  • Analog Output: Some MQ sensors output analog signals, requiring an ADC (Analog-to-Digital Converter) since Pi lacks native analog inputs.

Example Python snippet for PMS5003 particulate sensor:



<span><span><span>import</span></span><span> serial<br><br>ser = serial.Serial(</span><span><span>'/dev/ttyS0'</span></span><span>, baudrate=</span><span><span>9600</span></span><span>, timeout=</span><span><span>2</span></span><span>)<br><br></span><span><span>while</span></span><span> </span><span><span>True</span></span><span>:<br> data = ser.read(</span><span><span>32</span></span><span>)<br> </span><span><span>if</span></span><span> data[</span><span><span>0</span></span><span>] == </span><span><span>0x42</span></span><span> </span><span><span>and</span></span><span> data[</span><span><span>1</span></span><span>] == </span><span><span>0x4d</span></span><span>:<br> pm2_5 = (data[</span><span><span>12</span></span><span>] &lt;&lt; </span><span><span>8</span></span><span>) | data[</span><span><span>13</span></span><span>]<br> </span><span><span>print</span></span><span>(</span><span><span>"PM2.5:"</span></span><span>, pm2_5, </span><span><span>"µg/m³"</span></span><span>)<br></span></span>

This simple script logs live PM2.5 values.




4. Visualizing & Logging Data​


Once you have readings, Raspberry Pi makes it easy to store and visualize data:


  • CSV / SQLite: Log data locally for offline analysis.
  • Grafana + InfluxDB: Build beautiful real-time dashboards.
  • Home Assistant: Integrate air quality sensors into your smart home.
  • Cloud Platforms: Send data to AWS IoT, Azure, or Google Cloud for large-scale projects.

You can even build a local web dashboard using Flask or Node.js to monitor air quality on any device at home.




5. Projects & Use Cases​


  • Indoor Air Quality Monitor: Track CO2 and VOCs to know when to open windows.
  • Outdoor Pollution Tracker: Measure PM2.5 during wildfire season.
  • Smart HVAC Control: Automate fans, filters, or humidifiers based on sensor data.
  • Citizen Science Networks: Contribute data to open projects like Luftdaten or OpenAQ.
  • Workplace Safety: Monitor industrial or workshop air for harmful particles.



6. Expanding with IoT​


Air quality monitors get more powerful when connected to IoT systems:


  • Publish readings via MQTT to smart home hubs.
  • Trigger alerts via SMS/Email when pollution exceeds thresholds.
  • Share data to community dashboards for collaborative monitoring.
  • Combine with AI models to predict pollution patterns.



Conclusion​


Raspberry Pi + air quality sensors empower anyone to become their own environmental scientist. From monitoring indoor CO2 levels to mapping pollution in cities, these projects give real-time visibility into something often invisible but vital: the air we breathe. Whether it’s a personal health tool, a classroom experiment, or a citywide sensor network, the Pi makes air quality monitoring accessible, affordable, and impactful.




👉 Article includes:


  • History
  • Networking & Connectivity
  • Programming & Languages
  • Hardware & Accessories
  • Operating Systems
  • Getting Started
  • Top 25 Projects
  • Creative Builds
  • Educational Projects
  • Servers & Cloud
  • Robotics & AI
  • Media Centers & Entertainment
  • Home Automation & IoT
  • Air Quality Sensors
 
Last edited:
Back
Top