How do you feel about this article? Help us to provide better content for you.
Thank you! Your feedback has been received.
There was a problem submitting your feedback, please try again later.
What do you think of this article?
In addition to the sensor kit, SensorAIRium consists of three parts:
- The PureData patch (which creates the sounds / music)
- The adapter script (data interface)
- An Arduino (responsible for controlling the light)
As the audio output of the Raspberry PI is covered by the case of the beta kit, we’re using an external USB audio card (which looks like a cable) and is available for a couple of dollars. Of course, when modifying the case, it is possible to use the audio interface included in the Raspberry Pi. The SensorAIRium software itself is portable so it can also be theoretically used on a standard PC or laptop with Linux.
And here's how the final product looks like:
The project can also be used without an Arduino. But without light, it’s half the fun, isn’t it?
Step 1 – Getting started with the Air Quality Device
If you already have a working standard system image of the AQ device which can be accessed via SSH, you’re ready to go and can skip to Step 2. If not, please hang in there.
First, you need to download the system image from the AQ website (https://downloads.designspark.io/projects/aq-device/images/aq-device-LATEST.zip). After downloading the file from the web site you need to unzip it and then use an imaging tool such as the RPI imager (die hards use dd at their own peril). However, network configuration and setting passwords is so much easier using the tool. Please keep in mind that you might need root privileges in order to run it. Using the RPI imager, the system image has to be selected first. To do this, you need to click on "Choose OS" and then "Use custom". Then you can select the IMG file.
After the SD card is attached to the computer, you have to select the destination target using “CHOOSE STORAGE”.
Additional configuration is being performed by clicking on the cog wheel. For instance, the PI can connect automatically to the WIFI network (instead of using a LAN cable). The SSH service should be started (which is to allow a remote terminal). Also, the standard password can be changed here which is highly recommended.
After this, pushing the WRITE button will write the image. After finishing the process, the SD card can be inserted into the Raspberry PI and the PI itself into the casing. After all this is done and the PI is connected to power, it will take a while and the Raspberry PI image will configure itself. After a while, air quality values should be displayed on the LCD screen. Well done!
Step 2 – Connecting via SSH
If all went well, the Raspberry PI is also connected to the network. To check if that’s the case, the Raspberry PI can be “pinged” in the local network. Using a terminal on another computer just try “ping -c 3 airquality.local”.
If that does not work and there is an error like "airquality.local: Name or service not known" you might check on your router if the Raspberry PI was able to connect to the network. If not, probably something went wrong with the password?! If it works, ssh firstname.lastname@example.org will connect to the Raspberry PI. First time doing this, you might be quoted to accept the fingerprint with “yes”. After this, the default or changed password of the Raspberry PI needs to be entered. If you see “pi@airquality” – you got in :)
Step 3 – Installing Pure Data
After login in via remote shell (please make sure you’re really on the Raspberry PI (remember: there’s a pi@airquality in the prompt), proceed with
sudo apt update
Hit ENTER and wait. When done
sudo apt upgrade
Hit ENTER, confirm the question with ENTER and wait
After this, your Raspberry PI has the most recent repositories and software version.
Now, you can install Pure Data using
sudo apt install puredata
Hit ENTER and wait until the installation has been completed. Now is a good time to reboot. Enter reboot followed by ENTER and after a while (please have a look at the LCD screen on the Raspberry PI), you can login again using SSH.
Step 4 – Installing SensorAIRium
Now, the GIT repository with the pure data patch needs to be downloaded onto the Raspberry PI (/home/pi directory).
git clone https://github.com/oliverkrusede/SensorAIRium.git
If the sound card is connected, pure data should be able to play a sound using the following command:
pd -audiodev 3 -nogui PD/sound.pd
you can stop playing te patch using CTRL-C
-audiodev 3 selects the audio device. In most cases “3” should be the correct audio device.
If it is not, “pd -listdev -nogui” followed by CTRL-C should show the available audio devices.
If you’ve changed the device number to something else than 3, you need to remember it, so you can change the entry in the service file.
Step 5 – Installing services
The next step is to copy the service files (located in /home/pi/SensorAIRium/Services/) to the correct location. To do this ensure, please make sure that you are in the appropriate directory /home/pi/SensorAIRium (cd ~/SensorAIRium ). Now copy the files with “sudo cp Services/* /etc/systemd/system/”.
If you’ve changed the number of the audio device, now is the time to change it in the service file. Execute nano /etc/systemd/system/pd-patch.service. Again, die hards use vim. Now change the “3” in the line “ExecStart=…” to whatever the number was you’ve been using to successfully test the PD-Patch.
To save and exit nano, first press CTRL-O then ENTER to save and then CTRL-X to quit.
Now we need to update the service dependencies. We can do that with:
sudo systemctl daemon-reload
We can now manually start the SensorAIRium as as service with:
sudo systemctl start pd-patch.service
and stop it using:
sudo systemctl stop pd-patch.service
The following step is not mandatory but required when you want to use the Raspberry PI as a standalone device. Here’s how to enable autostart on boot:
sudo systemctl enable pd-patch.service
sudo systemctl enable pd-adapter.service
then reboot with “reboot” to try it out!
Step 6 – Let there be light
For this “add on” you need an Arduino and a neopixel LED device, e.g. a ring with 24 LEDs. Wiring is easy. You need to connect it in the following way:
After you’ve created the circuit you need to flash the program.
The easiest way to flash a Arduino board is to install the Arduino Software. Make sure you have the neopixel library installed. There are a lot of tutorials which explain how you install the software and the required libraries.
In the source code of SensorAIRium/Arduino/AirSoundLED.ino you may want to adjust the number of LEDs:
#define NUMPIXELS 24 // Popular NeoPixel ring size
The program, that needs to be flashed on the board is located in Repository under “Arduino/AirSoundLED.ino”. After you’ve flashed this program on the board. And it is connect to power it will start to glow green, if nothing went wrong.
Now it’s time to connect the device to the RaspberryPI. This is done with a simple USB cable which attaches the Arduino as a serial interface to the Raspberry PI.
After you’ve connected the LED device you need to restart the service ( sudo systemctl restart pd-patch.service) or only start it (sudo systemctl start pd-patch.service) if the service was not running before.
If the light is not synchronized with the music yet, try to only restart the pd-adapter service with (sudo systemctl restart pd-adapter.service). If that does also does not work, just lookup the status of the service ( systemctl status pd-adapter.service) and look if there’s something wrong.
Still here? Great, I’m glad you made it :) - I hope it was comprehensive and easy enough to follow. Now have fun with your new way to “see” and “hear” airquality!
If you find a bug, please don’t hesitate to report it using GITHUB.