The AirGradient DIY Air Quality Sensor
As part of the AirGradient for Education series, this instruction teaches how to build a powerful PM2.5 fine dust sensor with AirGradient.
The sensor will display PM2.5, CO2, Temperature and Humidity on the display and can optionally send the data to any server for data logging (e.g. the AirGradient platform or any other cloud backend).
You will need some basic soldering skills and experiences with microcontrollers are a plus. However, even if you are a beginner, don’t worry we made our instructions really easy! Also, if you get stuck please get in touch with us. We are more than happy to help!
Skills and Equipment required
For this project you should be familiar with the following:
- Basic soldering skills. Both the D1 mini microprocessor and some of the components we use like the OLED display need to get the pins soldered onto it. It is not very difficult and you can learn it easily. Look for example on this tutorial.
- Soldering iron and solder for above
- A breadboard is helpful to fix the components during soldering
- A computer (Linux, Mac, or Windows) with the Arduino IDE installed to flash the software onto the D1 mini.
- A micro USB data cable to connect the D1 Mini to the computer for flashing and later for electricity. IMPORTANT: Many micro USB cables only provide charging but do not allow the data transfer for flashing. So please make sure you have a micro USB DATA cable.
- Wemos D1 Mini USD 2.24
- Wemos OLED display USD 2.47
- Plantower PMS5003 PM Sensor USD 13.89
- Senseair S8 CO2 Sensor USD 28.00
- SHT30 or SHT31 Temperature and Humidity Sensor Module USD 2.55
AliExpress might not ship to all countries. In case they do not ship to your country, please try and source the exact same component from elsewhere.
You do not need to put all sensors on the PCB, e.g. if you only want to measure PM2.5 you can just leave the CO2 and Temperature/Humidity sensor out.
NEW: Order PCBs or a complete build kit from us
Often it is difficult and time consuming to order the PCBs and all the components.
We now offer to send them to you for a small postage and handling fee. You can either get only the PCBs from us or a complete kit with all the components.
To do so, you can order through our AirGradient DIY Shop.
More details about the kits, can be found here.
Make your own PCBs
In case you want to make your own you can use our Gerber files .
Alternatively, you can open the PCB schematic in the Easyeda editor and order additional PCBs from there.
You can also build the sensor without the PCB by just soldering the sensor modules with wires directly to the Wemos D1 Mini.
It will then look like this.
And you can use the following schematics:
We would still strongly recommend you assemble it with a PCB as it will be easier and also more robust.
Jeff Geerling’s Video Instructions
Recently Jeff featured our DIY sensor on his you tube channel and created a very nice video guide on how to assemble the sensor.
Arduino Software Instructions and flashing of the D1 Mini with the AirGradient firmware
All software for the AirGradient DIY sensor is open source and you are free to use it in any way. For flashing the D1 Mini microcontroller with the firmware we will be using the well-known Arduino software. Please read the following blog post on how to install the Arduino software and also on how to install the D1 Mini board and the AirGradient Arduino library.
Flashing of the D1 Mini with the AirGradient firmware
Once you have the Arduino Software setup for the D1 Mini, you can flash it with the AirGradient firmware.
- Go to Tools, Manage Libraries, and then search for AirGradient and install the AirGradient library.
- Once it is installed, go to File, Example, AirGradient and select the PM OLED code
- Read the instructions on top of the example code and install the additional libraries and set the true/false for the sensors you are using
- Then flash this code the same way you flashed the BLINK example
- Once you have successfully uploaded the code you can continue building the hardware
Soldering the Components
Now that you have the firmware flashed, you can solder the components onto the PCB. Please make sure you solder the pins in the correct direction. We recommend you start in the following order:
OLED Display Soldering
If you have a breadboard at hand, we recommend that you fix the pins with the breadboard to ensure that they are straight as shown on this picture.
Wemos D1 Mini Soldering
Put the long female and male pins through the D1 Mini. Make sure that the female parts are on top of the D1 Mini as shown on this image:
Then connect the freshly soldered OLED display into the female pins to better hold them in place. Then turn the D1 Mini with the OLED display attached around and solder the pins onto the D1 Mini
Wemos D1 Mini Soldering onto PCB
The next step is to solder the D1 Mini onto the PCB. Please make sure you solder it the correct way. The micro USB port needs to face outwards. You can also compare the PIN labels on the PCB with the ones on the D1 Mini. You can either solder the D1 Mini directly onto the PCB or use the pin headers as a socket. If you solder it directly, please leave a small gap between the PCB and the D1 Mini to make sure the plug is accessible.
Important. If you use the display or RGB led shield, you need to solder the D1 Mini directly on the PCB without the pin headers as a socket as otherwise it becomes too high and does not fit the enclosure.
Now depending on what sensor modules you want to use, please proceed as below.
Soldering the SHT30/31 Module (Temperature and Humidity)
To solder the small pins onto the SHT30/31 module, you can use a breadboard again to fix it into place.
Then put the SHT30/31 module through the corresponding holes on the PCB and solder it onto the board. You only need to solder the four pins. No need to do anything with the two pins on the top of the sensor.
Soldering the Sensirion S8 Module (CO2 Sensor)
To solder the small pins onto the S8 module, you can use a breadboard again to fix it into place.
Please make sure that the PINS face downwards as can be seen on this image.
Then solder the CO2 sensor onto the PCB. It is important that the bottom side of the CO2 has enough air flow. So make sure the gap is sufficient. It might be a good idea to put it on a female pin socket but you can also solder it directly. You can use the pin that came with the D1 Mini but you need to cut them off to the required length.
Soldering the PMS5003 Module (PMS Sensor)
Normally the PMS5003 comes with a cable. As we will solder one end of the cable directly onto the PCB you can cut it in half. Then prepare the following four wires as per this image. Please make sure you cut the correct wires.
Then solder the cable onto the PCB. Please make sure that you solder the correct cable into the correct pin.
After you have soldered the cable onto the PCB connect the PMS5003 with the other end of the cable. Then screw the PMS5003 onto the PCB or use double sided tape.
Done & Enjoy
That’s all and you can now connect the D1 Mini with power and you should be able to see the display lighting up. If you flashed the Wifi version, you need to connect the D1 Mini to the wifi. To do this open youw Wifi Settings on the phone and look for a hot spot called “AirGradient xxx”. Then connect to it and enter your Wifi network credentials. It will then connect to Wifi and start displaying and sending the air quality data.
If there are any issues, you can double check this tutorial and also the images. If you still have problems, please feel free and get in touch with us!
3D Enclosure and Mount
You can also download STI 3D printer files to print an enclosure that exactly fits our PCB. The 3d enclosure consists of a top and bottom part. There are two different top parts depending on if you use the OLED display or not. Please note that if you use the OLED you need to solder the Wemos D1 mini directly on the PCB as otherwise it will become too high.
You can also print a small temperature probe that can be snapped onto the enclosure and thus you can move the temperature sensor outside the main enclosure to avoid the heat from the enclosure impacting the temperature reading.
Solutions for Schools
AirGradient offers a sophisticated Air Quality Monitoring Solution for Schools. You can connect these DIY sensors to our platform, integrate with many existing brands or use our professional AirGradient sensor.
If you are interested for a free trial, please contact us.
The AirGradient DIY sensor’s hardware and software is Open Source and licensed under the MIT license. So feel free to use it any way you like! However we would be happy to hear from you and also appreciate any link back to our page.
Copyright AirGradient Co. Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.