How to Build an Air Quality Sensor and Upload Data

2022-04-19 07:23:47 By : Ms. Sasha Ye

Become a citizen scientist by building your own DIY air quality station and uploading data to the Sensor.Community site.

Are you concerned about air pollution in your neighborhood? Then why not set up your own air quality station? It doesn't cost much to assemble from a few standard components and a couple of sensors to measure particulate matter levels, along with the temperature, pressure, and relative humidity.

You can also join thousands of others in uploading your data to the Sensor.Community citizen science project. We’ll show you how to assemble an air quality station, install the software, and get it up on the network in no time.

To build the air quality station, you’ll need a selection of standard electronic and other components.

What you’ll need:

Note: This is for the standard setup, but the Sensor.Community citizen science program supports a wide range of sensors.

Connect your NodeMCU board to a computer with a USB cable. On a Linux machine, the serial connection should work by default; on a Windows PC or Mac, you’ll need to install a driver. Driver links are as follows:

Open the CP210x folder and double-click on theCP210xVCPInstaller_x64 (or x86) application.

Open the CH341SER folder and double-click on the SETUP application.

Unzip the CP210x folder and double-click on the CP210xVCPInstaller_x64 (or x86) application. Restart your Mac.

Unzip the CH341SER folder and double-click on the SETUP application. Restart your Mac.

Next, you’ll need to flash the Sensor.Community firmware onto the NodeMCU. For this, download the Airrohr firmware flashing tool; choose the appropriate version for your computer’s operating system.

Run the application, select latest_en.bin (or another language version) from the firmware version dropdown menu, and click Upload to flash it to your connected NodeMCU board.

Note: If the flashing application says ‘No boards found’, choose the option with ‘usbserial’ in it from the Board dropdown.

It’s time to wire your your sensors to the NodeMCU board. If your BME280 doesn't have male pins, you’ll need to solder some onto it.

Connect the BME280 sensor to the NodeMCU v3 as follows:

Connect the SDS011 sensor to the NodeMCU v3 as follows:

You can find the wiring guides for other sensor combinations on the Airrohr GitHub page.

Related: The Best Apps and Sites to Check Air Quality Anywhere

When you first power up the air quality station, it will create a wireless hotspot with the name airRohr (or Particulate Matter or Feinstaubsensor) followed by the NodeMCU’s chip ID (e.g. 12980979). Note this number down, as you’ll need it for registering the station later.

Connect your computer to this wireless hotspot and point a web browser to to access its web dashboard. From here, go to Configuration > WiFi Settings, select your wireless router, and enter the password for it.

Click the Save configuration and restart option to save the settings and restart the station. It will then connect to your wireless network and be reachable at its allocated IP address; to discover this, look in your router’s devices list for a device called ‘Airrohr-’ followed by its chip ID.

Visit its IP address in your web browser and you can then finish the configuration. In the Configuration > Sensors tab, make sure the sensors you’re using are ticked. Click the Save configuration and restart option to save the settings.

Reconnect to its web dashboard and click on Current data to check that everything is working. Note that it may take a couple of minutes for it to take the first readings.

To enable your station to upload data to the Sensor.Community website, you’ll need to register it there. Head to the devices login page and create an account.

Log in and go to My sensors > Register new sensor. For Sensor ID, enter the chip ID number you noted down; for Sensor Board, select ‘esp8266’.

Fill in the Basic and Additional Information, then check that the correct sensors are selected in Hardware Configuration. Choose your station’s location on the map and click Save settings.

It will take a couple of minutes for the station to start uploading data to Sensor.Community—you can check by clicking the Data button for it on the My sensors page; you can also Show it on map.

To protect your station from the elements when placed outdoors, you can house it inside a couple of interlocking plastic downpipe bends.

Insert the electronic components into one of the pipe bends. Depending on the type of pipe used, you may be able to position the dust sensor further up and connect the flexible plastic tubing to its shiny metal air input. You can then run the tubing to the end of the pipe, along with the BME280 sensor.

Our square pipe bends weren’t wide enough to push the dust sensor far up, so we placed it nearer the end and didn’t really need the flexible tubing, although we did add a short length.

Place the NodeMCU board further up, near the join with the second pipe bend, and run the USB power cable through the end of that pipe section. Secure this and the sensors to the sides of the pipe with sticky putty or strips.

Once you’re happy, and have ensured the station is working, wrap duct tape around the join of the pipe bends. If you want to prevent insects and other creepy-crawlies getting into the station, you can also put some fine mesh over the pipe ends.

It’s recommended to position your weatherproofed air quality station in a suitable spot outdoors, preferably 5 to 12 feet above the ground and well ventilated. We secured ours under a roof gutter using three daisy-chained cable ties. Alternatively, you can secure it to a downpipe.

To power your air quality station, you may need a long USB cable to reach a power socket indoors. If your station is too far from your wireless router to maintain a good signal, you may also consider placing a WiFi range extender nearer to the station.

By visiting the Sensor.Community world map, you can check out your station (and all the others) and view its current readings and recent data in graphs for the last 24 hours and rolling average over a week.

Particulate matter levels for PM2.5 (fine particles with a diameter of 2.5 μm or less) and PM10 (coarse particles) can be viewed. You can also use the bottom left menu to view temperature, pressure, and relative humidity.

You have now assembled your own air quality station and can view its data on a world map, along with that from thousands of other stations around the globe. Not only is it a cool project, but you will be contributing valuable data to the Sensor.Community citizen science program.

Phil is the Junior Editor for DIY projects at MUO and a freelance writer and editor with 20+ years of experience. He has edited numerous official Raspberry Pi books and is a regular contributor to The MagPi magazine.

Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!