Skip to main content
Build a Sub-$60 Air Quality Monitor on a Raspberry Pi 4 (CO₂, PM2.5, VOC)

Build a Sub-$60 Air Quality Monitor on a Raspberry Pi 4 (CO₂, PM2.5, VOC)

NDIR CO₂, laser PM2.5, VOC index — full BOM, wiring, and Home Assistant integration

Build a Raspberry Pi 4 air quality monitor with real NDIR CO₂, laser PM2.5, and VOC sensing for under $60. Full BOM, wiring, and dashboard.

You can build a working CO₂, PM2.5, and VOC monitor around a Raspberry Pi 4 8GB for well under $60 total. The Pi handles sensor I/O over I2C plus a local dashboard, integrates cleanly with Home Assistant via MQTT, and delivers accuracy within a usable margin of $300 commercial units for anything short of lab certification. Expect a Saturday of build time, roughly $50–$60 in sensors + Pi + wiring, and readings you can actually act on.

Why commercial CO₂ monitors cost $300+ and what a Pi build changes

Commercial indoor air quality monitors — Awair, Aranet, Kaiterra — are $200–$500 devices doing about $40 of work. The premium buys polished industrial design, a cloud app, and (in the higher tiers) NDIR CO₂ sensors that produce trustworthy parts-per-million readings. What you don't get is control over your data, the ability to add sensors, or integration with your home automation stack beyond a walled-garden API.

A DIY Pi 4 build inverts every one of those trade-offs. You buy a real NDIR sensor for $30–$50 (instead of the $5 metal-oxide "eCO₂" module that shows up in cheap boxes), wire it to the Pi 4's I2C bus, run a Python script, publish over MQTT to Home Assistant, and pay nothing per month. The tradeoff is enclosure aesthetics — your device looks like a Pi in a case, not a Braun Industrial concept — and about a weekend of setup time.

For readers building a first air-quality box, the pitch is: you'll spend under $60 to get within measurement-error-band of a $250–$300 commercial unit, and you'll actually understand which sensor is telling you what. That understanding is the biggest hidden benefit.

Key takeaways

  • Build cost: ~$55 in parts (Pi 4 8GB assumed) — NDIR CO₂ sensor ($30–$50), PM2.5 sensor ($15–$25), VOC sensor optional ($8), wiring and case ($10).
  • Accuracy: NDIR CO₂ ±50 ppm; PM2.5 ±10 µg/m³. Comparable to consumer-tier commercial devices.
  • Sensors that matter: SCD41 (Sensirion NDIR CO₂), SPS30 (Sensirion PM2.5), SGP41 (Sensirion VOC).
  • Data pipeline: Python on the Pi → MQTT → Home Assistant / Grafana.
  • Time investment: 2–4 hours of wiring, script setup, and dashboard configuration.

What you'll need checklist

  • Raspberry Pi 4 Model B 8GB — 4GB works too but 8GB gives you room for Home Assistant later
  • microSD card, 32GB+ or, better, a USB SSD like the Crucial BX500 1TB for reliability
  • Power supply — official Pi 4 5V/3A USB-C PSU
  • Sensirion SCD41 breakout (NDIR CO₂, $40 street) — the accurate CO₂ sensor
  • Sensirion SPS30 breakout (PM2.5, $25 street) — laser scatter PM sensor
  • Sensirion SGP41 breakout (VOC, $8 street) — optional, useful for indoor VOC awareness
  • Female-to-female jumper wires and a small breadboard
  • Small case or 3D-printed enclosure with intake vents
  • Optional: OLED display for local readout, small buck converter for stable 3.3V rail

For a starter kit with a case and PSU already included, the Raspberry Pi Zero W Basic Starter Kit is a workable substitute for the sensor logger only (not the dashboard), if you want a low-cost sensor endpoint that reports to a separate Pi 4 or NAS running the dashboard.

Which sensors matter?

The single biggest quality decision is CO₂. Cheap "eCO₂" sensors on Amazon are metal-oxide-based (MOX) and produce an estimated CO₂ value from other gases (mostly VOCs and humidity). They drift, they lie, they respond to nail polish remover as if it were carbon dioxide. Do not build your air quality monitor around one.

NDIR (non-dispersive infrared) CO₂ sensors measure CO₂ optically — they shine an infrared beam and measure how much a specific wavelength was absorbed. That's a real physics measurement, and it's why NDIR sensors cost $30+ instead of $5.

Sensor comparison at 2026 prices:

SensorTypeAccuracy (real-world)PriceNotes
Sensirion SCD41NDIR CO₂±50 ppm$40Best-in-class small NDIR
Winsen MH-Z19BNDIR CO₂±50 ppm$30Cheaper NDIR alternative, larger form factor
CCS811MOX eCO₂Poor (drifts)$8Do NOT use for real CO₂ measurement
Sensirion SPS30Laser PM±10% for PM2.5$25Reference-tier consumer PM sensor
Plantower PMS5003Laser PM±10% for PM2.5$20Widely used in AirGradient / PurpleAir
Sensirion SGP41VOC indexRelative index only$8Not a specific gas concentration
BME680Bosch multi-sensorApproximate VOC, temp, humidity, pressure$12Useful for indoor climate; VOC index only

For under $60 in sensors alone: SCD41 + SPS30 + SGP41 covers CO₂, PM2.5, and a VOC index. Add BME680 or BME280 if you want temperature/humidity/pressure without a second sensor.

How do you wire the sensors to the Pi 4's I2C?

Every Sensirion sensor above speaks I2C (or STC-based UART on some SPS30 variants). Wiring is minimal:

  • Sensor VCC → Pi 3.3V (pin 1)
  • Sensor GND → Pi GND (pin 6)
  • Sensor SDA → Pi SDA (pin 3, GPIO2)
  • Sensor SCL → Pi SCL (pin 5, GPIO3)

All I2C sensors share the same SDA/SCL lines. Each sensor has a distinct I2C address (SCD41 default 0x62, SPS30 default 0x69, SGP41 default 0x59, BME680 default 0x77), so they coexist on one bus. Use a small breadboard for prototyping; solder to a proto-HAT once you're happy with the layout.

Enable I2C in raspi-config (Interfacing → I2C → Enable). Confirm sensor detection with i2cdetect -y 1 — you should see each sensor's address in the grid.

How do you read and log the data? (Python + dashboard)

Sensirion ships Python libraries for each sensor. A minimal reader script:

  • Poll SCD41 every 30 seconds for CO₂ / temperature / humidity
  • Poll SPS30 every 60 seconds for PM1.0, PM2.5, PM4.0, PM10
  • Poll SGP41 every 30 seconds for VOC index (with the required conditioning routine)
  • Publish each reading over MQTT to a broker (Mosquitto running locally is fine)
  • Optionally write to SQLite or InfluxDB for local history

Systemd unit files keep the script running through reboots. Total code is under 200 lines of Python. Sensirion publishes reference implementations you can adapt.

For a UI, three options:

  1. Home Assistant with MQTT integration — best if you already run HA
  2. Grafana + InfluxDB — best for pretty graphs and time-series analysis
  3. A minimal Flask dashboard — simplest for a single-page local readout

Push readings into Home Assistant or Grafana

Home Assistant path:

  • Add the MQTT integration if not already configured
  • Create MQTT sensor entities in configuration.yaml for each metric (CO₂, PM2.5, VOC index)
  • Build a dashboard card with historical graphs
  • Set up automations — e.g., trigger a bathroom fan when CO₂ crosses 1000 ppm, or send a notification when PM2.5 crosses 35 µg/m³

Grafana + InfluxDB path:

  • Run InfluxDB (or InfluxDB 2 with Flux) on the Pi 4 or a separate machine
  • Have the Python script write directly to InfluxDB via its client library
  • Point Grafana at InfluxDB and build dashboards with query builder
  • Set alerts for threshold crossings

Both stacks scale — you can add more sensor endpoints (a Pi Zero W in each room, for example) reporting to the same broker or database.

What accuracy can you actually expect vs a $300 commercial unit?

Sensirion SCD41 typical accuracy: ±(50 ppm + 5% of reading) for CO₂. That's the same accuracy class as Aranet4 (which uses a similar-tier NDIR sensor). Commercial-tier NDIR sensors from Vaisala or LI-COR reach ±20 ppm at 5–10× the cost, aimed at HVAC certification and research use — not what a household user needs.

For PM2.5, the SPS30 tracks well against reference-grade AlphaSense OPC-N3 sensors used in academic PM studies. It's the sensor behind AirGradient's respected community-tier air monitors.

For VOCs, the SGP41 reports a relative index rather than a ppm concentration. It's useful for "how VOC-loaded is the air right now vs baseline" but you cannot calibrate it to "you have 200 ppb of benzene."

Bottom line: for practical air-quality awareness — when to ventilate, when to run an air purifier, is this room's CO₂ climbing too fast — a $55 DIY Pi build lands in the same measurement-error band as a $200–$300 consumer commercial unit.

Cost breakdown and where to save vs where not to

ItemCostSave on this?
Pi 4 8GB~$75Substitute 4GB or Pi Zero 2 W for logger endpoints (~$15)
microSD 32GB$12Use a SATA SSD for reliability if long-running
Power supply$10Do not save. Bad PSUs cause undervoltage warnings
SCD41 CO₂ sensor$40Do NOT save. This is the sensor that makes the build honest
SPS30 PM2.5 sensor$25Slightly cheaper Plantower PMS5003 works too
SGP41 VOC$8Optional; skip if you only need CO₂ + PM
Wiring + breadboard$8
Case$103D-print or Amazon
Total~$55–$85(excluding Pi 4 you already own)

Do NOT save on the CO₂ sensor. That's the difference between a device that tells you "your room needs ventilation" and a device that tells you "some kind of chemistry is going on nearby."

Bottom line: is the DIY monitor good enough for real decisions?

Yes, for the decisions most people actually make:

  • When to open a window / run a fan: yes
  • When to run the air purifier: yes
  • Whether a room is fresh or stale for guests: yes
  • Home Assistant automation triggers: yes
  • Feeding data to a research paper: no (you'd want reference-grade sensors)
  • Legal HVAC certification: no (you'd want calibrated commercial units)
  • Occupancy-based ventilation control at a building: yes, with proper enclosure and validation

For a homeowner or renter who wants real, actionable air-quality data at 20% of the commercial-unit cost, the answer is unambiguously yes. Build it.

Real-world example: three-sensor Pi 4 build

A weekend build for under $60 in sensors (assuming you already own the Pi 4):

  1. Cut a 3D-printed case with intake vents around the SPS30 fan intake
  2. Solder a HAT-style prototype board with the three sensors
  3. Wire I2C to the Pi's GPIO header
  4. Boot Raspberry Pi OS Lite, enable I2C in raspi-config
  5. Clone Sensirion's Python examples for each sensor, adapt them into a single logging script
  6. Install Mosquitto MQTT broker on the same Pi
  7. Point Home Assistant (running on the same Pi or another host) at the MQTT topics
  8. Build a dashboard card, set a CO₂ > 1000 ppm notification
  9. Watch a week of data to calibrate your intuition

Total time investment: 4–6 hours across a weekend. Total ongoing cost: electricity (~$4/year at ~3W idle).

Common gotchas

  • Undervoltage warnings. Buy the official Pi 4 5V/3A power supply. Skimping causes SD card corruption over time.
  • SD card wear. Continuous logging to microSD kills cheap cards in months. Move to USB SSD (Crucial BX500 1TB is fine) or reduce log frequency.
  • Missing I2C address in i2cdetect. Confirm SDA/SCL wiring, sensor power (3.3V not 5V), pull-up resistors on the bus.
  • PM sensor fan noise. SPS30 has a small fan; not silent. Locate the box away from bedrooms.
  • SGP41 needs conditioning. First readings after cold-start are unreliable; Sensirion's driver handles this if you use the reference implementation.

Related guides

Citations and sources

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

Products mentioned in this article

Tap any product for full specs, live Amazon & eBay pricing, and alternatives.

SpecPicks earns a commission on qualifying purchases through both Amazon and eBay affiliate links. Prices and stock update independently.

Frequently asked questions

Do I need a Raspberry Pi 4 or will a cheaper board work?
A Pi 4 comfortably runs the sensor scripts, a local dashboard, and a Home Assistant integration at once, making it the easy choice. A Pi Zero 2 W or a microcontroller can handle a single-sensor logger for less money and power, but the Pi 4's headroom simplifies adding sensors, dashboards, and future features.
Why do NDIR CO₂ sensors cost more than cheap ones?
NDIR sensors measure CO₂ optically and give true, stable parts-per-million readings, while inexpensive metal-oxide sensors only estimate an equivalent CO₂ from other gases and drift significantly. For decisions like when to ventilate a room, the accuracy of a real NDIR sensor is worth its higher price over a guessing MOX unit.
Can this feed into Home Assistant?
Yes. You can publish the Pi's sensor readings over MQTT or expose them as a local API, and Home Assistant ingests them as sensor entities for dashboards, history graphs, and automations like triggering a fan when CO₂ rises. This integration is a major advantage of a Pi build over a sealed commercial monitor.
How accurate is a DIY monitor versus a $300 unit?
With a quality NDIR CO₂ sensor and a decent PM2.5 sensor, a DIY Pi monitor lands within a usable margin of pricier commercial units for everyday awareness. It will not carry lab calibration certificates, but for knowing when to open a window or run an air purifier, the readings are accurate enough to act on confidently.
Does the Pi need to run headless?
Running the Pi 4 headless, without a monitor or keyboard, is the typical setup: you access it over SSH or a web dashboard and let it log continuously in the background. Headless operation saves power and desk space, and pairs well with a small case tucked near where you want to measure air quality.

Sources

— SpecPicks Editorial · Last verified 2026-07-10

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 →