Skip to main content
Raspberry Pi Air Quality Sensor Guide: Setup & Sensor Picks

Raspberry Pi Air Quality Sensor Guide: Setup & Sensor Picks

A synthesis of manufacturer datasheets and public wiring guides for building a Pi-based air quality monitor

How to wire, calibrate, and log data from a Raspberry Pi air quality sensor — PMS5003, SGP41, and MQ135 compared, per public datasheets.

Building a Raspberry Pi air quality sensor rig means picking the right sensor for what you actually want to measure — particulates, VOCs, or broad-spectrum gases — then wiring it to the correct interface and validating the readings against a public reference. This guide walks through sensor selection, wiring, calibration practice, and a Pi 4 vs Pi 5 comparison for this specific use case, drawing on manufacturer datasheets and public documentation rather than a first-party build.

How to Connect an Air Quality Sensor to a Raspberry Pi

Raspberry Pi boards don't have native analog inputs, which shapes which interface each sensor needs:

  • UART (serial) — sensors like the PMS5003 stream continuous particulate readings over a simple serial connection to the Pi's GPIO UART pins. Per Adafruit's PM2.5 sensor guide, this is one of the most straightforward wiring paths for beginners since it needs no additional converter chip.
  • I2C — sensors like the SGP41 communicate over the two-wire I2C bus, which the Pi exposes natively on its 40-pin header. Sensirion's SGP41 product page documents the I2C command set and notes the sensor is commonly paired with a temperature/humidity sensor (such as the SHT4x) for compensated readings.
  • Analog via ADC — sensors like the MQ135 output a raw analog voltage, which the Pi cannot read directly. An external ADC (MCP3008 over SPI, or ADS1115 over I2C) is required to bridge the analog signal into a digital value the Pi can process.

For a first build, an I2C or UART sensor is simpler because it avoids the extra ADC step. Readers running a broader sensor cluster may also want to review Raspberry Pi 5 Power Supply: What You Actually Need — adding a particulate sensor's fan/laser assembly and a display can push a Pi 4 or Pi 5 build past what a marginal USB charger can reliably supply.

Top Raspberry Pi–Compatible Air Quality Sensors Compared

SensorMeasuresInterfaceNotes
PMS5003PM1.0 / PM2.5 / PM10 particulatesUARTLaser-scattering particle counter; widely used in DIY air-quality builds per Adafruit's wiring guide
SGP41VOC + NOx indexI2CSensirion's gas-index algorithm runs on-chip; commonly paired with SHT4x for humidity compensation
MQ135Broad-spectrum gases (NH3, CO2, benzene, smoke)Analog (needs ADC)Simple, low-cost, but requires an ADC and a burn-in period before readings stabilize, per common hobbyist datasheets

Each sensor answers a different question. PMS5003 is the right pick if the goal is tracking wildfire smoke or general particulate pollution. SGP41 fits indoor air quality projects focused on off-gassing (paint, furniture, cleaning products). MQ135 is a cheaper, less selective option better suited to rough gas-presence alerts than precise concentration readings.

Calibrating Readings Against Reference Data

Low-cost sensors drift and read differently from EPA-grade reference monitors, so calibration matters if the goal is anything beyond relative trend-watching. The EPA's Air Sensor Toolbox documents best practices for siting, co-locating, and cross-checking low-cost sensors against reference-grade instruments before trusting absolute numbers.

For particulate readings specifically, the EPA publishes standard PM2.5 AQI breakpoints that any Pi-based dashboard can map raw µg/m³ readings against:

AQI CategoryPM2.5 (µg/m³)
Good0.0 – 12.0
Moderate12.1 – 35.4
Unhealthy for Sensitive Groups35.5 – 55.4
Unhealthy55.5 – 150.4
Very Unhealthy150.5 – 250.4

(Breakpoints per the EPA's AQI Basics documentation.)

A Python script can bucket PMS5003 output into these categories directly, giving a human-readable AQI label instead of a raw particle count. For VOC/gas sensors, Sensirion's SGP41 documentation recommends stable placement away from direct airflow and heat sources rather than a fixed recalibration interval, since the sensor's on-chip algorithm adapts its baseline over time.

Raspberry Pi 4 vs Raspberry Pi 5 for This Project

Neither the PMS5003 nor the SGP41 is bandwidth- or compute-intensive, so a Raspberry Pi 4 handles a basic sensor-logging script without strain. Where the newer board matters is in what runs alongside the sensors:

Raspberry Pi 4Raspberry Pi 5
CPUQuad-core Cortex-A72 @ 1.8GHzQuad-core Cortex-A76 @ 2.4GHz
I/OUSB 3.0 + GPIO UART/I2C/SPIUSB 3.0 + GPIO, PCIe 2.0 x1 (via adapter), dedicated RP1 I/O chip
Fit for this projectSufficient for sensor polling + light loggingBetter if also running a local dashboard, database, or NVMe-backed long-term storage

Per Raspberry Pi's own product pages for the Pi 5 and Pi 4, the Pi 5's faster CPU and separated RP1 I/O controller are the meaningful upgrades — neither is specific to sensor polling, but both help if the same board is also serving a Grafana dashboard or running a database. Readers weighing a Pi 4 vs Pi 5 purchase for a broader home-lab build may find Raspberry Pi 4 8GB vs Pi 5 vs Mini-PC for Local LLMs useful context on where the performance gap actually shows up.

Logging and Visualizing the Data

A typical public build pattern looks like:

  1. A Python script polls the sensor (UART read for PMS5003, I2C command/response for SGP41) on a fixed interval.
  2. Readings are written to a local time-series store or a simple CSV/SQLite file.
  3. A lightweight dashboard — commonly Grafana reading from InfluxDB, or a periodic matplotlib chart — renders trends over time.
  4. Optional: readings above a threshold (e.g., crossing into the EPA's "Unhealthy for Sensitive Groups" band) trigger a notification.

This is the same general logging pattern used across most Pi-based home telemetry projects — readers already running a broader self-hosted stack can slot air-quality logging alongside existing services covered in Build a Self-Hosted AI Home Lab on a Raspberry Pi 4 8GB, since the sensor script itself is lightweight enough to run alongside other Pi workloads without dedicating a separate board.

Where This Fits in a Broader Raspberry Pi Build

An air quality sensor is often one piece of a larger single-board-computer project list. For readers scoping out what else a Pi can realistically do in 2026, Raspberry Pi 5 Projects Worth Building in 2026 rounds up other builds worth considering on the same board. If the eventual plan is to pair environmental logging with a local AI assistant or query interface, Raspberry Pi LLM Projects: What Actually Runs in 2026 and Raspberry Pi LLM GPU Guide: What Actually Works in 2026 cover what's realistic to run locally on the same hardware class. For anyone scaling beyond one Pi — say, multiple sensor nodes reporting to a central board — Raspberry Pi LLM Cluster: What It Can (and Can't) Do and Raspberry Pi vs AMD GPUs for Local LLMs: What the Specs Show lay out the compute ceiling of a Pi-based cluster. And since sensors, fans, and displays all draw current a stock USB charger may not reliably supply, Raspberry Pi 5 Power Supply: What You Actually Need is worth checking before final assembly.

Citations and sources

  • https://www.raspberrypi.com/products/raspberry-pi-5/
  • https://www.raspberrypi.com/products/raspberry-pi-4-model-b/
  • https://www.raspberrypi.com/documentation/computers/raspberry-pi.html
  • https://learn.adafruit.com/pm25-air-quality-sensor
  • https://sensirion.com/products/catalog/SGP41
  • https://learn.adafruit.com/adafruit-sgp40
  • https://www.epa.gov/outdoor-air-quality-data/air-quality-index-aqi-basics
  • https://www.epa.gov/air-sensor-toolbox

This piece is editorial synthesis based on publicly available information. No independent first-party benchmarking is reported.

Sources

— SpecPicks Editorial · Last verified 2026-07-22

More guides & deep dives from the SpecPicks archive

Browse all articles & guides →

More reviews from the SpecPicks archive

Browse all reviews →

More buying guides from SpecPicks

Browse all buying guides →