DELIVERY ALL OVER PAKISTANFast delivery across Pakistan
STEM.pk
Login Cart

Measure Indoor Air Quality with the PMS5003 Sensor and Arduino

Smog season makes PM2.5 a daily topic in Lahore and across Punjab. With a Plantower PMS5003 laser dust sensor and an Arduino, you can build your own monitor and see what the air inside your home or classroom is actually like.

How the PMS5003 works

A small fan pulls air past a laser. Particles in the air scatter the light, and the sensor counts and sizes them. It reports mass concentration in micrograms per cubic metre (µg/m³) for three sizes: PM1.0, PM2.5 and PM10.

What you need

  • PMS5003 sensor with its cable
  • An Arduino Uno or Nano
  • Jumper wires

Wiring

The sensor needs 5 V to run its fan, but its data pins use 3.3 V logic.

PMS5003 pin Connect to
VCC (pin 1) Arduino 5V
GND (pin 2) Arduino GND
TX (pin 5) Arduino pin 2 (software serial RX)
RX (pin 4) Not needed for reading

The Arduino only needs to listen, so you can leave the sensor’s RX pin unconnected. If you do send commands to it, put a voltage divider on that line, because a 5 V Arduino pin can damage the 3.3 V input.

The data frame

The sensor sends a 32-byte frame about once a second at 9600 baud. It always starts with the bytes 0x42 0x4D. Bytes 12–13 hold the PM2.5 value for normal atmospheric conditions, and the last two bytes are a checksum equal to the sum of the first 30 bytes.

Arduino code

#include <SoftwareSerial.h>
SoftwareSerial pms(2, 3); // RX, TX

uint8_t buf[32];

void setup() {
  Serial.begin(9600);
  pms.begin(9600);
}

bool readFrame() {
  if (pms.available() < 32) return false;
  if (pms.read() != 0x42) return false;
  if (pms.peek() != 0x4D) return false;
  buf[0] = 0x42;
  pms.readBytes(buf + 1, 31);
  uint16_t sum = 0;
  for (int i = 0; i < 30; i++) sum += buf[i];
  return sum == ((buf[30] << 8) | buf[31]);
}

void loop() {
  if (readFrame()) {
    uint16_t pm1  = (buf[10] << 8) | buf[11];
    uint16_t pm25 = (buf[12] << 8) | buf[13];
    uint16_t pm10 = (buf[14] << 8) | buf[15];
    Serial.print("PM1.0: ");  Serial.print(pm1);
    Serial.print("  PM2.5: "); Serial.print(pm25);
    Serial.print("  PM10: ");  Serial.println(pm10);
  }
}

Open the Serial Monitor at 9600 baud. Give the sensor about 30 seconds after power-up for the fan to settle before trusting the readings.

What do the numbers mean?

The World Health Organization’s 2021 guideline for PM2.5 is an annual average of 5 µg/m³ and a 24-hour average of 15 µg/m³. Readings far above that, which are common outdoors in winter in Lahore, are a reason to keep windows closed and run an air purifier if you have one. Compare readings before and after cooking, sweeping or running a purifier to see how much each one changes indoor air.

Ideas to take it further

  • Add a small OLED display so the monitor works without a computer.
  • Use an ESP8266 or ESP32 instead of an Arduino to log readings to the internet.
  • Average readings over a minute to smooth out short spikes.