Skip to main content
shopping_basket Basket 0
Log in

sensorAIRium - Turns air quality into an experience of light and sound - Part V

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.

Start screen of Raspberry Pi imager

Custom image

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.

Advanced options

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”.

Ping as a connection test

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 pi@airquality.local 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).

cd ~
git clone https://github.com/oliverkrusede/SensorAIRium.git
cd SensorAIRium

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.

Overview of audio devices(

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.

Editing the sound device in services

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:

Wiring of NEOPIXEL to Arduino

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.

Other parts in this series are:

  • Part I -   Introduction - A simple idea
  • Part II -  Transport the data stream into PURE DATA
  • Part III - Diving deeper into the world of PURE DATA
  • Part IV - Visual aspects
I am an IT expert which is interested in machine user interaction, music and arts. In the late 90s I have developed music instruments and music software. I'm working in the IT industry for over 20 years now - and it's getting more exciting every day. Programming and development of hard- and software components and doing music is something I do together with my kids in my leisure time.
DesignSpark Electrical Logolinkedin