Ryder Damen on Tom's Hardware has a straightforward project - How to make a Raspberry Pi Home Air Quality Monitor. After a small bug fix, it worked well.
My hardware:
- Raspberry Pi 3
- Nova PM SDS011 sensor
Clean Raspberry Pi Install
Hardware:
- SanDisk microSD card
- SanDisk microSD-to-SD adapter
- Apple USB-C SD card reader
Software:
- Raspberry Pi Imager
I just followed the steps on Getting Started - Setting up your Raspberry Pi.
I downloaded the Raspberry Pi Imager, installed it on my Mac, and then installed the default Raspberry Pi OS 32 bit image on my MicroSD card.
I used the advanced options available in Imager by clicking the cogwheel in order to set the Raspberry Pi device name and a non-default username and password for the root account.
Once the MicroSD was reformatted and had the Raspberry Pi OS installed and verified on it, I safely ejected the card (actually I just powered down the Mac, which has the same effect).
Insert the MicroSD and Power Up the Pi
With a new clean install of Raspberry Pi OS ready on the MicroSD, I inserted the MicroSD into the Raspberry Pi and powered up.
I already have a keyboard and mouse on a USB hub (so a single USB-A connector) and a small HDMI monitor.
For networking I just plugged the Raspberry Pi directly into my Ethernet network.
Everything booted up fine, I disabled Bluetooth since it was unnecessary and then I opened a command line and followed the article steps. I did everything with the root account, which is not a best practice but is the fastest way to get going for this type of single-use experiment.
Follow the Article Steps
After that I just followed the steps in the article.
https://www.tomshardware.com/how-to/raspberry-pi-air-quality-monitor
-
sudo apt-get update && sudo apt-get install -y git
-
cd ~/ git clone https://github.com/rydercalmdown/pi_air_quality_monitor.git
-
cd pi_air_quality_monitor make install
-
make build
make build will take some time. It took about 15 minutes on my Raspberry Pi 3. But you only have to do it once.
- Connect the SDS011 sensor to the USB adapter it comes with using the provided jumper cable, then
Connect the SDS011 USB adapter to your Raspberry Pi. - There is a bug in the code
You need to edit the file
src/templates/index.html
and change the line (line 35)
$.getJSON('http://10.0.0.172:8000/api/', function(data) {`
to
$.getJSON('/api/', function(data) {`
You can use e.g. the built-in nano editor to do this edit. (I have also submitted it on GitHub as a pull request - 17 Update index.html)
Otherwise without this change the hardcoded web address (IP address) will cause the web server to fail with a misleading error.
-
make run
- Navigate to your Pi’s local IP (127.0.0.1) address on port 8000 to view the web server, and a graph of recent measurements of air quality.
i.e.
http://127.0.0.1:8000/
IMPORTANT NOTE: This web page does not auto-refresh. It will start out as a blank graph underneath the text "Raspberry Pi Air Quality Monitor". You have to manually reload the page (by e.g. clicking the circle arrow) to get the latest data.
Many people were saying their sensor or the code wasn't working, but actually all you need to do is reload the web page.
Any Port in a Particle Storm
I was worried that the four USB ports on my Pi 3 would have some unique numeric binding, but they don't. With my keyboard and mouse on a single connection through a USB hub, and the SDS011 as the only other USB device, whichever port I plugged the SDS011 into became ttyUSB0 , so it wasn't an issue.
Testing 999
As the reading is normally just steady, I did a -- NOT RECOMMENDED AT HOME -- smoke test by intentionally burning some toast. This set off my fire alarm and also caused my Temtop M10 PM2.5 sensor to go to its highest reading, 999.
The on-screen readings from the Nova PM SDS011 responded as expected, so it definitely works.
I also ended up doing an unintentional smoke clearing test, which told me that it takes my air filters 40 minutes to clear the air from unsafe to safe levels.
The Raspberry Pi graph responded to the declining counts as I would expect. The count wasn't exactly the same as the Temtop M10, but this is to be expected as the Nova PM 2.5 is reading over a shorter time interval.
Going Public
Be aware that this web server is also running on your Raspberry Pi's public IP, not just on localhost. I solved that problem simply by pulling the Ethernet cable, but you may not have such an easy solution depending whether your Pi is on Wi-fi and what else you are doing with your device.
Conclusion
With the exception of the bug (which the code author really should fix) and the fact that the web page doesn't auto-refresh, this is a quick and easy project to get your own PM2.5 (and PM10) sensor readings.
Bug aside, thanks to Ryder Damen for making such a straightforward no-solder project possible.
Security Note
You should be mindful of the security issues that might be associated with running this as a service on port 8000 of your Pi's public IP (ideally the code should be modified to allow the option of a local service only).
Annex: Buying a Nano PM SDS011
I could only find a wide variety of vendors on Amazon.
I'm in Canada, I got my SDS011 on Amazon Canada from risingsaplings in the States for $55. I liked that it shipped from Amazon USA, so that I had confidence there actually was a real product and that its shipping would be well tracked.
/risingsaplings-Precision-Quality-Detection-Digital/dp/B0BPQQ24ZR/
You can get much cheaper prices from Amazon Canada by going with other vendors that ship themselves from Canada. Just search for SDS011. I can't provide any comment on the other vendors or the reliability of their shipping, I have no idea.
Comments