A MicroPython driver for the SDS011 particle sensor (PM10 and PM25). This sensor uses serial communication.
On a LoPy, just put sds011.py
in the lib/
directory.
On a NODEMCU ESP32 put sds011.py
in the root directory.
First, import the library:
import sds011
Next, initialize a UART object (here P21 in TX and P22 is RX):
uart = UART(1, baudrate=9600, pins=('P21','P22'))
For NODEMCU ESP32 choose:
uart = UART(1, baudrate = 9600, rx = 16, tx = 17)
Since we have the UART bus object, we can now use it to instantiate the SDS011 object:
dust_sensor = sds011.SDS011(uart)
To read from the sensor:
dust_sensor.read()
print('PM25: ', dust_sensor.pm25)
print('PM10: ', dust_sensor.pm10)