Particulate matter measurement with the Raspberry Pi
Charly's Column – Raspberry Pi
Whether you can breathe easily or not depends on what is in the air. Is there too much particulate matter that could be harmful to your health? A particulate matter measurement provides clarity – and the Raspberry Pi can help.
How fresh is the air I breathe? To find out, I put my own particulate matter measuring station into operation. Particulate matter (PM) is a mixture of all kinds of organic and inorganic dusts, bacteria that travel through the air, and many other particles that do not exceed 10 micrometers in size.
The above measurement is why we use the term PM10. For comparison, a hair has a diameter of 50 to 75 micrometers. Today, even smaller particles with a size of only 2.5 micrometers (PM2.5) or smaller are considered separately because they penetrate deep into the airways and reach the alveoli.
There are several sensors on the market that can measure both PM classes. I chose the Nova SDS011 PM Sensor by Chinese manufacturer Nova Fitness Co., Ltd. The sensor draws air into a chamber and shoots a laser at it. It uses the dispersion of the reflected light to determine the particle size and quantity. It delivers the data via a serial interface.
A USB adapter is included with the sensor, making it easy to connect to the Raspberry Pi. After connecting, I can see from the syslog that the /dev/ttyUSB0
interface is now available:
[ 2.611448] usb 1-1.5: ch341-uart converter now attached to ttyUSB0
The manufacturer's data sheet [1] reveals that the interface must be set to 9600bps with 8 data bits, no parity, and one stop bit. The stty
command handles this:
stty -F /dev/ttyUSB0 9600 raw
The data sheet also says that the sensor operator can expect the values in hexadecimal notation in a fixed, recurring order once per second. The output looks like this:
0000000 aac0 8c00 9400 bcf9 d5ab
This means that values are now available: 8c
for the PM2.5 class and 94
for PM10, 140, and 148 decimals.
The data sheet contains the following computation formula: The decimal value of the high byte is multiplied by 256, and the decimal value of the low byte is added to it. The result has to be divided by 10 – this is finally the PM value in micrograms per cubic meter of air. In the example, this would be 14 micrograms/m3 for the PM2.5 class, a low (i.e., good) value. You can then use RRDtool [2] to show your data in graph format (Figure 1).
Infos
- Laser dust sensor control protocol: https://cdn.sparkfun.com/assets/parts/1/2/2/7/5/Laser_Dust_Sensor_Control_Protocol_V1.3.pdf
- RRDtool: https://oss.oetiker.ch/rrdtool/
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.