How to build a mobile particulate matter sensor with a Raspberry Pi

How to build a mobile particulate matter sensor with a Raspberry Pi

Monitor your air quality with a Raspberry Pi, a cheap sensor, and an inexpensive display.

Team communication, chat
x

Subscribe now

Get the highlights in your inbox every week.

About a year ago, I wrote about measuring air quality using a Raspberry Pi and a cheap sensor. We've been using this project in our school and privately for a few years now. However, it has one disadvantage: It is not portable because it depends on a WLAN network or a wired network connection to work. You can't even access the sensor's measurements if the Raspberry Pi and the smartphone or computer are not on the same network.

To overcome this limitation, we added a small screen to the Raspberry Pi so we can read the values directly from the device. Here's how we set up and configured a screen for our mobile fine particulate matter sensor.

Setting up the screen for the Raspberry Pi

There is a wide range of Raspberry Pi displays available from Amazon, AliExpress, and other sources. They range from ePaper screens to LCDs with touch function. We chose an inexpensive 3.5″ LCD with touch and a resolution of 320×480 pixels that can be plugged directly into the Raspberry Pi's GPIO pins. It's also nice that a 3.5″ display is about the same size as a Raspberry Pi.

The first time you turn on the screen and start the Raspberry Pi, the screen will remain white because the driver is missing. You have to install the appropriate drivers for the display first. Log in with SSH and execute the following commands:

$ rm -rf LCD-show
$ git clone https://github.com/goodtft/LCD-show.git
$ chmod -R 755 LCD-show
$ cd LCD-show/

Execute the appropriate command for your screen to install the drivers. For example, this is the command for our model MPI3501 screen:

$ sudo ./LCD35-show

This command installs the appropriate drivers and restarts the Raspberry Pi.

Installing PIXEL desktop and setting up autostart

Here is what we want our project to do: If the Raspberry Pi boots up, we want to display a small website with our air quality measurements.

First, install the Raspberry Pi's PIXEL desktop environment:

$ sudo apt install raspberrypi-ui-mods

Then install the Chromium browser to display the website:

$ sudo apt install chromium-browser

Autologin is required for the measured values to be displayed directly after startup; otherwise, you will just see the login screen. However, autologin is not configured for the "pi" user by default. You can configure autologin with the raspi-config tool:

$ sudo raspi-config

In the menu, select: 3 Boot Options → B1 Desktop / CLI → B4 Desktop Autologin.

There is a step missing to start Chromium with our website right after boot. Create the folder /home/pi/.config/lxsession/LXDE-pi/:

$ mkdir -p /home/pi/config/lxsession/LXDE-pi/

Then create the autostart file in this folder:

$ nano /home/pi/.config/lxsession/LXDE-pi/autostart

and paste the following code:

#@unclutter
@xset s off
@xset -dpms
@xset s noblank
 
# Open Chromium in Full Screen Mode
@chromium-browser --incognito --kiosk http://localhost

If you want to hide the mouse pointer, you have to install the package unclutter and remove the comment character at the beginning of the autostart file:

$ sudo apt install unclutter

I've made a few small changes to the code in the last year. So, if you set up the air quality project before, make sure to re-download the script and files for the AQI website using the instructions in the original article.

By adding the touch screen, you now have a mobile particulate matter sensor! We use it at our school to check the quality of the air in the classrooms or to do comparative measurements. With this setup, you are no longer dependent on a network connection or WLAN. You can use the small measuring station everywhere—you can even use it with a power bank to be independent of the power grid. 


This article originally appeared on Open School Solutions and is republished with permission.

About the author

author
Stephan Tetzel - I'm a teacher and IT system administrator in an international school in South-East Asia. I love open source software and I used it over a decade in my private and work life. My passion is to solve problems with open source software! I blog on https://openschoolsolutions.org. Follow me on Medium or Twitter