The Raspberry Pi needs software to power the SDS011 and collect the data it produces. Ours improves on other software available online, we think, because:
- It measures consistently, without wild swings due to mathematical errors
- It produces a local and an online copy
- It extends the useful life of the sensor by powering it down between measurements
To use our software in its basic form, there are three steps, explained below:
- Download this package to your main computer and unzip it
- Copy it to the desktop of your Pi with RealVNC.
- Create a startup script that will start the software every time the Pi boots
Step 1: Downloading the package from adamnorman.com
This should be easy. I’ll leave you to it. Download this.
Step 2: Copying the files to the desktop
RealVNC allows you to copy files between your server (the Pi) and your viewer (your computer). As of June, 2018, the process for doing so (on a Mac) is as follows:
Open RealVNC on the Pi by clicking on the black and blue VNC icon in the top right of the Pi’s menu bar. Open “File Transfer” from the hamburger menu.
Select the desktop for the location your files will be saved to under the “Fetch Files to” option box, and close that dialog.
Placing your cursor on the menu bar of the RealVNC client window. Click on the two-way arrows.
Click on “Send Files” to send the files you unzipped on your computer to the desktop of the Pi.
Your files should now appear as a folder on the Pi’s desktop. Important: the program will only work if it’s installed on the desktop.
Step 3: Creating a boot process
You will now force the Pi to start the measurement software every time it boots up. Unfortunately, this step requires using the Terminal, which is a pain. Not to worry, though; you only need to type, and you won’t need to understand what you’re typing.
Open the Terminal by clicking on the raspberry in the top left, then “Accessories”, then “Terminal”.
Now type: “sudo nano /etc/rc.local”. This will open a very ugly, very tiny version of Microsoft Word right in the Terminal window. You’ll use this word processor to edit one of the files the computer reads when it starts (the file is called rc.local).
Move the cursor (with your keyboard arrow keys) to the line that says “fi” in green. Press Enter or Return on your keyboard to make a new line.
Type (or copy) the following words into the document, on the blank line below the word “fi”: “sudo python3 /home/pi/Desktop/AQM/main.py &”
Press Ctrl-X, and save your work.
The computer will read rc.local when it boots, and will start the program main.py when the it boots.
We still need to build the sensor, but the programming part is done!