SDS011 sensor data for air quality measurement

I got a Nova Fitness SDS011 sensor for measuring air quality. It has a serial interface and outputs data with 9600 baud. The serial interface pins Rx and Tx are specified as TTL with 3.3V levels.

It can be plugged into a USB port via the serial/USB converter (based on an CH340 IC) it is shipped with. dmesg outputs the following system log:

usb 2-1.2: ch341-uart converter now attached to ttyUSB0

Check lsusb‘s output:

Bus 002 Device 005: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

It uses a baud rate of 9600 (ssty). The serial data stream can be formatted with od as stream of hexadecimal numbers and printed to stdout:

# od -x < /dev/ttyUSB0 
0000000 c0aa 001a 001c 4bea ab6b c0aa 001a 001d
0000020 4bea ab6c c0aa 001a 001d 4bea ab6c c0aa
0000040 001a 001d 4bea ab6c c0aa 001a 001d 4bea
0000060 ab6c c0aa 001a 001d 4bea ab6c c0aa 001a
0000100 001e 4bea ab6d c0aa 001a 001e 4bea ab6d

The UART protocol (described in the datasheet) uses a packet of 10 Bytes sent each second. It contains two 16-bit values for both PM2.5 and PM10.

The blog article “Feinstaubmessung mit dem Raspberry Pi” [German] gives a good introduction of how to work on the raw data. It also provides an explanation of how to calculate the particulate matter measurement data in µg/m³ from the raw values. You can also find a Bash script on that site which can help as a “getting started” guide.

After some modifications you get two values per second (indoor test):

$ ./ 
preamble ok
[2017-03-20 19:40:50] particulate matter PM25: 14.8 µg/m³
[2017-03-20 19:40:50] particulate matter PM10: 36.1 µg/m³
preamble ok
[2017-03-20 19:40:51] particulate matter PM25: 14.9 µg/m³
[2017-03-20 19:40:51] particulate matter PM10: 36.4 µg/m³
preamble ok
[2017-03-20 19:40:52] particulate matter PM25: 14.9 µg/m³
[2017-03-20 19:40:52] particulate matter PM10: 36.4 µg/m³

The Bash script currently does not calculate and check the checksum which is also transmitted within the UART data stream.

Bern Laquai used an Arduino and described his step in the document “Arduino-basierte Auswertung von Messdaten und Data- Logging für den Feinstaubsensor SDS011 von Nova Fitness” [German pdf file].

The sensor itself has a limited service lifetime of “up to 8000 hours” – which would translate to 333.3 days or not even a whole calendar year. To prolong the service lifetime it’s recommended to power down the sensor and use it in a discontinuous way.

Possible next steps: use a simple wireless NodeMCU, add temperature and humidity sensor(s) and contribute to projects like “ – Feinstaub selber messen“.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s