PM2.5 Air Quality Sensor
Created by lady ada
Last updated on 2018-08-22 04:05:03 PM UTC
Guide Contents
Guide Contents
Overview
Arduino Code
Wiring
CircuitPython Code
Downloads
Files:
2
3
5
5
9
12
12
© Adafruit Industries
https://learn.adafruit.com/pm25-air-quality-sensor
Page 2 of 12
Overview
Breathe easy, knowing that you can track and sense the quality of the air around you with the PM2.5 Air Quality
Sensor with Breadboard Adapter particulate sensor.
Mad Max & Furiosa definitely should have hooked up one of
these in their truck while scavenging the dusty desert wilderness of post-apocalyptic Australia
(https://adafru.it/CiF).
And for those of us not living in an Outback dystopia, this sensor + adapter kit is great for monitoring air quality, and
super easy to use!
WITNESS
real-time, reliable measurement of PM2.5 dust concentrations! (PM2.5 refers to particles that are 2.5 microns
or smaller in diameter.) This sensor uses laser scattering to radiate suspending particles in the air, then collects
scattering light to obtain the curve of scattering light change with time. The microprocessor calculates equivalent
particle diameter and the number of particles with different diameter per unit volume.
© Adafruit Industries
https://learn.adafruit.com/pm25-air-quality-sensor
Page 3 of 12
You'll need to hook this up to a microcontroller with UART input (or
you could theoretically wire it up to a USB-Serial
converter and parse the data on a computer
(https://adafru.it/C7B))
- we have code for both Arduino and CircuitPython.
9600 baud data streams out once per second, you'll get:
PM1.0, PM2.5 and PM10.0 concentration in both standard & enviromental units
Particulate matter per 0.1L air, categorized into 0.3um, 0.5um, 1.0um, 2.5um, 5.0um and 10um size bins
As well as checksum, in binary format (its fairly easy to parse the binary format, but it doesn't come out as pure
readable ascii text)
We give you the sensor box as well as the cable and a 0.1" / 2.54mm breakout board so you can wire it easily. You only
need power plus one data pin (for the UART TX). Power is 5V, logic is 3.3V
© Adafruit Industries
https://learn.adafruit.com/pm25-air-quality-sensor
Page 4 of 12
Arduino Code
This code will get you started with any Arduino compatible (e.g. Arduino UNO, Adafruit Metro, ESP8266, Teensy, etc.
As long as you have either a hardware serial or software serial port that can run at 9600 baud.
Wiring
Wiring is simple! Power the sensor with +5V and GND and then connect the data out pin (3.3V logic) to the serial input
pin you'll use. Whether or not you are using hardware or software UART/serial may affect the pin, so adjust that as
necessary. This wiring works for ATMega328P-based boards for sure, with Digital #2 as the data pin:
Upload this code to your board, and open up the serial console at 115200 baud
// On Leonardo/Micro or others with hardware serial, use those!
// uncomment this line:
// #define pmsSerial Serial1
// For UNO and others without hardware serial, we must use software serial...
// pin #2 is IN from sensor (TX pin on sensor), leave pin #3 disconnected
// comment these two lines if using hardware serial
#include <SoftwareSerial.h>
SoftwareSerial pmsSerial(2, 3);
void setup() {
// our debugging output
Serial.begin(115200);
// sensor baud rate is 9600
pmsSerial.begin(9600);
}
struct pms5003data {
uint16_t framelen;
uint16_t pm10_standard, pm25_standard, pm100_standard;
uint16_t pm10_env, pm25_env, pm100_env;
uint16_t particles_03um, particles_05um, particles_10um, particles_25um, particles_50um, particles_100um;
uint16_t unused;
© Adafruit Industries
https://learn.adafruit.com/pm25-air-quality-sensor
Page 5 of 12