A re you curious how you can contribute to a citizen science initiative? Does the idea of building your own electronics to analyse the environment around you sound exciting? Then I have a project for you!

Today we welcome guest author Ganesh Shankar, tinkerer and engineer. Stick around until the end for ways to connect and engage with him.

I will show you how easy it is to build a device that can monitor air quality and contribute the data collected to Sensor.community (formerly Luftdaten), a global network of DIY environmental sensors.

So we can have some fun and learn together – I’ve chosen a path that is on the more accessible end but still requires some DIY electronics, building, and coding. This project will use the incredible Raspberry Pi platform and an Enviro+ Air Quality monitor HAT as a sensor package. You’ll need some basic skills in electronics, programming and configuring Internet of Things (IoT) devices.

Raspberry Pi circuit board

What we will be building together is just one available option for those looking to collect and contribute air quality data. If you think this project looks too easy or too hard, know there are many other options from building and programming everything yourself to buying an off-the-shelf solution that just needs power and the internet. So I encourage you to search for modifications that work for you.

Before we dive in, let me give you a bit of background as to why I’m so passionate about this project, because if nothing else, I would love to convince you that understanding the quality of the air around you is so important.

QUICK LOOK

  • Air pollution kills about 7 million people a year.
  • Scientists need your help in collecting global air quality data.
  • We will be building an at-home air quality monitor using Raspberry Pi and Enviro +.
  • You’ll need very basic maker skills.
  • Use your data for personal use or to add to global air quality research.

My Background and Why Air Quality is Important

Most of us know inherently how vital a healthy diet is. Similarly, clean air is important to our health and wellbeing. According to the WHO, air pollution kills an estimated 7 million people every year. Human-driven industrial activity (e.g., factories, transportation, agricultural burning) and climate change (e.g., larger, more frequent fires) are further exacerbating the problem. 

When I was two years old, I was diagnosed with Asthma, a chronic condition I’ve lived with all my life. Being an asthmatic makes you very aware of the air quality around you, as irritants like pollution, smoke, pollen, and dust can quickly leave you out of breath and possibly even in a life-threatening situation.

I’ve lived in Singapore, Australia, and Germany, three countries with very different air quality characteristics, and three different experiences for me as an asthmatic. 

Singapore’s Air Quality

Singapore is a highly developed city that enjoys better air quality than most Asian cities. However, I remember distinctly from my childhood an annual phenomenon called “The Smog” when asthmatics and those with respiratory issues were told to stay indoors. The Smog was a human-created issue caused by farmers in nearby Indonesia doing mass burnoffs during the dry season to clear land for palm oil and paper plantations.

Neon light display in Singapore

Australia’s Air Quality

Australia, being sparsely populated and with lower industrial activity than other countries, enjoys relatively low pollution from human-made sources. In general, air quality in the southern hemisphere is better due to it being less populated than the northern hemisphere. However, that doesn’t mean that air quality isn’t a concern in Australia; substantial pollen blooms during springtime and extreme weather create risky scenarios such as thunderstorm-triggered asthma attacks. Also, hotter and drier weather driven by climate change leads to more frequent and more significant bushfires in summer, another primary air pollution source in Australia.

Australian bottlebrush

Germany’s Air Quality

For the last six years, I’ve been living in Munich, Germany, where my sensitivity to pollen and smoke has been at its lowest. However, mainland Europe has had to keep a close eye on pollution created by industrial activity and diesel vehicles, which are notoriously bad for making the particulate matter that most of us think of as air pollution. During lockdown in Germany, I noticed that my apartment’s air quality was declining, likely because my partner and I were home more often.

As you can see, many factors influence the air quality in your region. As with all good science, we need data and a lot of it to understand the world around us. By collecting an accurate picture of air quality trends in your area, you can help researchers looking for a robust dataset and also use this data yourself to advocate for improvements with your local representatives.

At a very pragmatic level, you can even use your sensor to help you understand when to open your windows to improve the air quality inside your home and when to shut them to avoid dangerous conditions. Airing out of your house or apartment can be critical to health. Here in Germany, some rental contracts require you to open your windows for 10 minutes a day to get ‘Frische luft’ for good health. 

Did you know that new furniture and textiles can pollute your apartment or house over several years and airing out your place is essential to keeping you in good health?

I hope I’ve convinced you to at least become more interested in the air quality around you. For those who want to dive deeper to contribute to citizen science and improve air quality, let’s get making.

Let’s Nerd Out About Technology’s Contribution to Citizen Science

Before we dive into the project, I want to share a bit of background on the technology we’re working with and why we live in such an exciting time for citizen science and technology projects.

I’ve always been a giant nerd, fascinated with taking technology apart and building computers from a young age. When I started my career as an electrical engineer, it used to be extremely difficult and expensive to mess around with electronics – which meant only the most dedicated hobbyists dabbled in making circuits. Scientific instruments were considered specialised instruments to manufacture, and sharing data with the world was a significant challenge.

Thankfully, a few innovations over the past 10 years have lowered the barrier to entry, meaning that it’s relatively easy to create basic electronics projects and have a lot of fun along the way. If you’ve ever wanted to automate some of the lights in your home, set up a wildlife camera, or create a weather station, we live in a time where technology has made these projects easy to do for almost anyone. Open-source hardware like the Raspberry Pi, make getting started a breeze.

Introduction to Raspberry Pi

Why Use Raspberry Pi?

For our project, I’ve selected the Raspberry Pi as the platform on which to build on. 

The Raspberry Pi is a low-cost computing device designed by an open-source foundation looking to promote basic computer science teaching in developing countries. By creating straightforward and hardy miniaturised computers that fit on a single circuit board (about the size of the palm of your hand), the device became popular with makers who wanted an easy way to experiment with sensors and robotics.

Since its early years, the Raspberry Pi has gone through four iterations of the design, resulting in a larger format B model, and a compact Zero model. The beauty of the Raspberry Pi is that it is cheap with a low barrier to entry; if you can use a computer, then you can use a Raspberry Pi. 

The Raspberry Pi runs a Linux operating system and has networking, video, audio, and USB built-in so you can plug it into power, a screen, monitor, and keyboard and write programs for it from the device itself!

HATs for everyone

The other attraction of the Raspberry Pi is the community of independent hardware vendors who make add-ons called HATs. If you look at the Raspberry Pi board, you’ll see a double-row of pins sticking out from one side. 

Raspberry Pi computer show in a hand for size

The metal pegs along the top are for easy attachment of HATs.

These pins allow access to power and input/output control signals from the device itself, making attaching custom hardware to the computer trivial. These easy connections encouraged many manufacturers to create modules that can slot into the header and add some superpowers to the Raspberry Pi.

These modules are called HATs, which stands for Hardware Attached on Top. Welcome to the wonderful world of Engineering humour 🙂 The HATs allow for easy customisation and the magical ability to turn a Raspberry Pi for all sorts of citizen projects. Enviro+ sensor HAT for rasperry Pi in someone's hand

HATs have a row of slots to place on top of the Raspberry Pi.

Materials You’ll Need

We will use the compact Raspberry Pi Zero W for our project. Being compact means it is less powerful, saving energy and space (but still more than powerful enough for our needs). The W in the name means that this model comes with networking in-built, which is important for connecting to wifi and sending data to Sensor Community. I would recommend purchasing this model, which comes with the Header (the rows of pins) pre-installed, so you don’t need to do any soldering at all! – unless you want to, of course. I discuss both options below. 

display of materials needed for the citizen science project

The next piece of hardware we’re going to use is the Enviro + Air Quality HAT sensor HAT created by Pimoroni. All the sensors we need for this project are conveniently packaged into a small circuit board ready to slot on top of the Raspberry Pi Zero W – convenient, right?

Finally, we will need the PMS5003 Particulate Matter Sensor, which will plug and play with our Enviro + board. Without it, you could still make a pretty fun sensor package. However, it’s useful for recording outdoor air quality and sending data on the particulate matter to Sensor.community allowing us to measure PM 2.5 and PM10 data.

particulate sensor added to the raspberry pi

Some additional bits and bobs you’ll need:

  • A computer to set up and configure the Raspberry Pi
  • Micro USB Power supply for your Raspberry Pi (an old phone USB charger should do, but you can also get an official Raspberry Pi one)
  • Micro SD Card (8Gb is plenty) to hold the operating system of your Raspberry Pi.
  • A way to read/write to your SD card from your computer.
  • PVC Drainpipe, zip ties, velcro command straps, and duct tape to mount your air quality monitor outside. Most of this can be found at a DIY store, so pick what works for you, but I’ll show you what I did later on.
  • [Optional] An anti-static work mat.
  • [Optional] A case for your Raspberry Pi like the Pibow Zero W, which protects it but leaves the header exposed so we can add the HAT
    • If you don’t want a case, I recommend getting four standoff screws to help mount the Hat securely.

Step 1 – Preparing Your Operating System

For the Raspberry Pi to work, you need to load an operating system to the micro SD card. Think of it as the same way a computer has a hard drive. The Raspberry Pi Foundation makes this super easy.

1.1 Visit https://www.raspberrypi.org/software/

1.2 Install the Raspberry Pi Imager onto your computer

1.3 Insert your micro SD card into your computer via an SD Card reader

1.4 Open the Raspberry Pi Imager and click Choose OS

Raspberry Pi OS

1.4.1 Click Raspberry Pi OS (other)

raspberry Pi operating system

1.4.2 Select Raspberry Pi OS Lite

Why select the Raspberry Pi OS Lite? It’s a version of the operating system that does not have a desktop environment, meaning we won’t be using applications on it like a browser, etc. Since we won’t be using our Raspberry Pi as a traditional computer, the Lite version is better. It’s faster to install, runs faster, and easy access remotely from our computer.

1.5 Select Choose SD Card and pick the micro SD card you inserted (you might need to format it)

1.6 Select Write and wait until the Raspberry Pi Imager says it’s done.

Now, because we installed Raspberry Pi OS Lite, there are a couple of additional configuration steps we want to do to preconfigure the device so we can remotely access it when we power it up.

1.7 To configure your device to connect to your Wifi and enable SSH (our way of connecting to the device remotely), follow these instructions.

1.8 Test the connection of your Raspberry Pi.

Simply insert the SD Card, power up the device, wait a couple of minutes, and then SSH into raspberrypi.local (or the IP address of the device you found earlier)

Curious? Subscribe!

Join the
Curious Animal Pack

Step 2 – Hardware Assembly

The second phase of our project involves assembling the Raspberry Pi, Enviro + HAT, and case if you have one.

working mat displaying hardware components

2.1 [If Required] Attach your header to the Raspberry Pi Zero W

I used a Pi Zero W Starter Kit for convenience, but note that this kit requires some basic soldering to attach the Pi Zero W board header. I have a soldering iron at home and was keen to dust off my skills, but if you’re not comfortable working with solder (it’s like a mix of hot glue and welding), then I recommend just buying the pre-assembled Pi Zero WH or the Starter Kit and a Hammer Header kit to make this step much more manageable.

My wife, Susanna, helped a bit while learninging to Solder for the first time. Get the whole family involved!

2.2 [Optional] Assemble the Pibow Case

Make sure your SD Card is inserted (as you won’t be able to get to it again quickly once you build the case), I assembled the Pibow Zero W as per this guide.

close up of the raspberry pi case being assembled

Assembling the Pi Bow case.

2.3 Attach the Enviro + Air Quality HAT

Follow this excellent guide from Pimoroni on attaching your Enviro + Air Quality Hat and testing its functions.

** Make sure when you push the HAT down onto the header pins to use gentle force. You will need to push a little but double-check to make sure it’s oriented the right way (the HAT should sit over the board) and with all pins aligned and don’t force it!

close up image of the air quality sensor

Enviro+ Hat is on and looking fashionable.

2.4 Attach the Particulate Matter Sensor

If you didn’t do so in the previous step, ensure your Raspberry Pi is powered off and attach the Particulate Matter Sensor – the cable only goes into the socket in one orientation, so use that gentle force once more.

Particulate Matter Sensor added to the Enviro+

Step 3 – Software Configuration and Testing

Now that we have the board assembled, we are done with the Hardware part – easy, right? Time to fire up our device and see how it works.

Since I recommended installing the headless Lite version of Raspbian OS, you’ll need to SSH into your device for this next part (the last part of this tutorial we did earlier when setting up the Operating System)

Once you have the Command Prompt of the Raspberry Pi up on your terminal, just resume the Pimoroni Getting Started guide at the step called Installing the Enviro+ Python library.

display of environmental data on a computerIf you’re able to successfully run the examples at the end (my favourite is the one that powers the little screen with data), then you are almost done! Congratulations, you’ve (hopefully) successfully assembled the hardware and software—Pat yourself on the back. 

Step 4 – Register to Contribute to Citizen Science

Now that we know our Raspberry Pi and air quality sensors are working, it’s time to contribute to the world of science!

For this part, we’re following this guide from Pimoroni, which takes the existing sensor package and adds a script that lets us talk to Sensor Community. You can skip most of the guide as we configured almost everything in Part 3, but make sure to review Installing the Enviro+ software as there is an additional step at the end of it. When following the guide on registering your device, note that Luftdaten is now called Sensor Community and has a slightly updated site. That said, the flow was ~90% the same.

**Note, if you get an error when trying to run the command:

python luftdaten.py

You might be missing a required Python module Requests, simply run the following command:

sudo pip install requests

Once I ran the command, the error resolved. 

4.1 Register an account with Sensor Community

Go to devices.sensor.community and follow their prompts to get set up and start contributing to citizen science. Make sure to do this before you place outside.

4.2 Register your sensor on Sensor Community

Use the number on the LCD while running: python luftdaten.py

registration page for sensor community

With that, our air quality sensor is ready to go into the outside world! They grow up so fast.

Step 5 – Weatherise for Outdoors

While the Raspberry Pi is a hardy little computing device, there are some precautions to take when putting electronics in the outdoors. We will need to ensure that we put our device into a weather-proof container while still allowing air sampling access. You may want to take precautions to prevent birds/animals from building nests in there too.

I followed the Mounting your Enviro+ in the weatherproof housing section of the same Pimoroni Guide as Step 4. Unlike the rest of our project, you can feel free to be creative here. It’s unlikely you’ll be able to find the same type of piping in all parts of the world, so just find some PVC drainpipe that you can assemble to hold the device. Make sure it’s waterproof and aimed downwards so air can still get in, but water can’t.

Building a pipe case for the air sensor

**Note: When assembling the case, it might be a little challenging to push the Raspberry Pi with its power cable into the pipe, especially if you used the same case and pipe. I found that removing two screws from the right side of the Pibow case (don’t worry, it won’t open) and using a wire clipper to strip off some of the bend protection on my micro-USB cable (we actually do want it to bend here) helped me make it fit snugly.

Finally, find a great place to mount your sensor (usually a drainpipe or balcony railing provides a right spot) we put ours on our balcony!

Step 6 – Analyse Your Sweet, Sweet Data

6.1 Go to devices.sensor.community and log in

6.2 Click on Data

6.3 Click on “Show on Map” to see the air quality data for your local area, centred on your device. 

You can change the filter on the bottom right to see various data like PM 2.5, PM 10 and Air Quality Index – pretty sweet, eh?

global air quality data

What is the official Air Quality (AQI) where you live? As you can see, they have great data coverage in Europe but could use additional sensors in other parts of the world. So, if you live in any of the other continent It would be super cool if you set one of these up and added your data.

Discuss and Share

How awesome does it feel to be a citizen scientist contributing data to help alleviate global air pollution?

I was thrilled to find this project and share it with you. I hope you found the same joy from learning a little about the world of electronics and citizen science data collection. The Raspberry Pi is a revolutionary device for the world of makers. I hope that once you’ve experienced how simple it is to create an air quality sensor, you’ll move on to other citizen science projects too! For something to noodle on, here are some ideas for other Citizen Science initiatives that use Raspberry Pi – from a traffic monitor to a wildlife camera and make sure you read all the ways you can get engaged as a citizen scientists – with no skills required!

  • What was your favourite part of this project?
  • Why is air quality important to you – what’s the quality like where you live?
  • What factors contribute to air quality (good or bad) in your home region? Industry, cars, fire, pollen? Or, maybe you live near a forest that cleans the air.
  • Do you have any questions – ask away!

Share your progress and answers to the questions with me in the comments, I look forward to reading them. Happy making and stay curious!

Build an Air Quality Sensor with Raspberry Pi and Enviro+