Weather & ScienceTechnician

Air Quality Monitor (PM2.5) with OLED Display

Measure fine particles from smoke, dust and cooking with a laser sensor over serial.

LevelTechnician
Time1.5 h
Est. cost~$60
Steps5

The PMS5003 laser sensor counts particles and sends a 32-byte frame over UART about once per second. You will decode it in Python and show PM2.5 on a tiny OLED.

Video tutorial

Video by DHK DUDE, embedded from YouTube. The written steps below are our own and match the parts list.

Mission steps

  1. Enable the serial port

    raspi-config → Interface → Serial: no login shell, hardware port on.

  2. Wire the sensor

    PMS5003 VCC to 5 V (its fan needs it), GND to GND, sensor TX to Pi RX (GPIO15, pin 10). Its data lines are 3.3 V.

  3. Read frames

    The script syncs on the 0x42 0x4D header and reads the atmospheric PM values.

  4. Add the OLED

    Wire the SSD1306 to I2C and display the PM2.5 value with a color-coded label.

  5. Interpret

    PM2.5 under about 12 µg/m³ is generally considered good; sustained high readings mean ventilate or filter the air.

Code

# pip install pyserial
import serial, struct
port = serial.Serial('/dev/serial0', 9600, timeout=2)

while True:
    if port.read(1) != b'\x42' or port.read(1) != b'\x4d':
        continue
    frame = port.read(30)
    if len(frame) != 30:
        continue
    vals = struct.unpack('>HHHHHHHHHHHHHHH', frame)
    pm1, pm25, pm10 = vals[4], vals[5], vals[6]      # atmospheric values
    print(f'PM1.0 {pm1}  PM2.5 {pm25}  PM10 {pm10} ug/m3')

Tip: test every script on the bench before installing it in a moving machine.

Questions

Is this as accurate as an official monitor?

Low-cost sensors track trends well but can read high in humid air. Treat them as indicators, not certified measurements.