adafruit_pm25

CircuitPython library for PM2.5 Air Quality Sensors

  • Author(s): ladyada

Implementation Notes

Hardware:

Works with most (any?) Plantower UART or I2C interfaced PM2.5 sensor.

Software and Dependencies:

class adafruit_pm25.PM25

Super-class for generic PM2.5 sensors.

Note

Subclasses must implement _read_into_buffer to fill self._buffer with a packet of data

read()

Read any available data from the air quality sensor and return a dictionary with available particulate/quality data

adafruit_pm25.i2c

I2C module for CircuitPython library for PM2.5 Air Quality Sensors

  • Author(s): ladyada

Implementation Notes

Hardware:

Works with most (any?) Plantower I2C interfaced PM2.5 sensor.

Software and Dependencies:

class adafruit_pm25.i2c.PM25_I2C(i2c_bus, reset_pin=None, address=18)

A module for using the PM2.5 Air quality sensor over I2C

Parameters:
  • i2c_bus – The busio.I2C object to use.
  • reset_pin (Pin) – Pin use to reset the sensor. Defaults to None
  • address (int) – The I2C address of the device. Defaults to 0x12

Quickstart: Importing and using the PMSA003I Air quality sensor

Here is one way of importing the PM25_I2C class so you can use it with the name pm25. First you will need to import the libraries to use the sensor

import board
import busio
from adafruit_pm25.i2c import PM25_I2C

Once this is done you can define your busio.I2C object and define your sensor object

i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)
reset_pin = None
pm25 = PM25_I2C(i2c, reset_pin)

Now you have access to the air quality data using the class function adafruit_pm25.PM25.read

aqdata = pm25.read()

adafruit_pm25.uart

UART module for CircuitPython library for PM2.5 Air Quality Sensors

  • Author(s): ladyada

Implementation Notes

Hardware:

Works with most (any?) Plantower UART or I2C interfaced PM2.5 sensor.

Software and Dependencies:

class adafruit_pm25.uart.PM25_UART(uart, reset_pin=None)

A driver for the PM2.5 Air quality sensor over UART

Parameters:
  • uart (UART) – The busio.UART object to use.
  • reset_pin (Pin) – Pin use to reset the sensor. Defaults to None

Quickstart: Importing and using the PMS5003 Air quality sensor

Here is one way of importing the PM25_UART class so you can use it with the name pm25. First you will need to import the libraries to use the sensor

import board
import busio
from adafruit_pm25.uart import PM25_UART

Once this is done you can define your busio.UART object and define your sensor object

uart = busio.UART(board.TX, board.RX, baudrate=9600)
reset_pin = None
pm25 = PM25_UART(uart, reset_pin)

Now you have access to the air quality data using the class function adafruit_pm25.PM25.read

aqdata = pm25.read()