Have you ever wondered about the quality of the air you are breathing, or maybe, why you sometimes feel sleepy in the office or tired in the morning even after sleeping all night? Poor air quality can lead to many negative health effects as well as can cause tiredness, headaches, loss of concentration, increased heart rate and so on. Monitoring the quality of the air may actually be more important than you realize. So, in this tutorial we will learn how to build our own Air Quality Monitor which is capable of measuring PM2.5, CO2, VOC, Ozone, as well as temperature and humidity.


I will explain how each of air quality parameters affect us and how the sensors work. The brain of this project is an Arduino Pro Mini board which in combination with a 2.8” Nextion touch display provides a decent user interface.

Arduino Air Quality Meter

We can see the measurements from all the sensors in real time, and if we click on a particular sensor, we will get values from the last 24 hours from that sensor. There’s also a dimming function through which we can lower the brightness of the display or even turn it off completely. This is convenient, for example, if we want to track the air quality in our bedroom during the night.

DIY Air Quality Monitor with last 24 hours sensors data storing

We can turn off the screen for the night, and the next day we can check the values from each sensor individually.

Nevertheless, now I will walk you through the entire process of building it and explain how everything works. At the end of this video, you will be able to build one on your own. So, let’s get started.

The PM2.5 Sensor – PMS5003

This device has four main components or air quality sensors. We are using the PMS5003 sensor for measuring PM2.5 or particulate matter in the air with diameter of around 2.5 microns. Particulates are the most harmful form of air pollution because they can penetrate deep into the lungs, blood streams and brain, causing many health problems.

PMS5003 - PM particulate matter sensor in a DIY Arduino Air Quality Monitor

This sensor works on the principle of laser scattering. The sensor has a fan which creates a controlled airflow so the environmental particulates pass through a focused laser beam.

How Particulate Matter PM Particles Sensor Works - Laser Scattering Working Principle

The particulates cause light scattering which is detected by a photodiode and then converted into PM concentration with the help of its microprocessor. I found the results of this sensor to be quite reliable and along PM2.5 it can also output PM1 and PM10 values.

The CO2 Sensor – MH-Z19

Next, we are using the MH-Z19 sensor for measuring CO2 or carbon dioxide. As people emit carbon dioxide while respiration, the indoor concentration of CO2 can easily get very high. CO2 is not only dangerous in high concentrations, but it can also cause drowsiness, tiredness, decrease our productivity level and so on.

MH-Z19 CO2 Sensor - Measuring Carbon Dioxide with Arduino

The sensor is using non-dispersive infrared principle for measuring CO2 in the air. An infrared source directs light through a tube which is filled with the air that we are measuring. On the other side of the infrared source, there is an optical filter and an IR detector which measures the amount of IR light that passes through.

non-dispersive infrared principle for measuring CO2 in the air

The CO2 gas molecules which are present in the air that we are measuring absorb a specific band of IR light while letting some wavelengths to pass through. So, the CO2 level is calculated according difference between the amount of light emitted and the amount of IR light received by the detector. The results from this sensor are also quite accurate.

The VOC and Ozone Sensors – MP503 and MQ-131

For measuring VOC and Ozone we are using the MP503 and the MQ131 gas sensors. These are heated metal oxide sensors and their principle of work is based on detecting change in resistance at the presence of targeted gases.

How Metal Oxide Sensors Work

A specific electrical current pass through a metal substrate and the resistance changes according to the amount of gas present.

The target gas of the MQ131 sensor is just Ozone, which in a normal household can be generated by products like certain air purifiers, facial steamers, germicidal lamps that produce ultraviolet light and so on.

MP503 VOC Sensor and MQ-131 Ozone Sensor

On the other hand, the MP503 sensor has multiple target gases, including alcohol, smoke, iso-butane, methanal and others. VOC stands for Volatile Organic Compounds and these are organic emission from products that we use on a daily basis like laundry detergents, cleaners, air fresheners, paint, makeup, and so on. VOCs can cause many negative health effects including headaches, irritation to eyes, skin reactions, dizziness and so on.

DIY Arduino Air Quality Monitor – Circuit Diagram

Nevertheless, so let’s take a look at the circuit diagram now and explain how everything needs to be connected.

DIY Arduino Air Quality Monitor Circuit Diagram - How It Works

You can get the components needed for this Arduino air quality monitor from the links below:

Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.

The PM2.5 sensor communicates with the Arduino through a serial interface. It works at 5V, but the receive RX logic level works at 3.3v, so therefore we need a voltage divider for it. The CO2 sensor and the Nextion display also use serial communication. For reading the VOC and the Ozone sensors we use analog inputs of the Arduino, while the DHT22 temperature and humidity sensor uses a digital pin for that purpose.

The two transistors are used for activating the sensors heaters. We are also using a Real Time Clock module for keeping track of the time when storing the sensors values, and it uses the I2C communication. The whole device is powered with 5V through a Mini USB connector.

Now if we try to connect everything together, we will get quite a mess because of the many connections.

Wiring mess using a breadboard

So, we definitely need a PCB for this project.

Making a PCB for the Arduino Air Quality Monitor

For making a PCB for this project, I’m going to use Altium Designer which are actually the sponsor of this video.

Altium Designer - Arduino Air Quality Monitor PCB 3D Model

Altium Designer represents decades of innovation and development dedicated to creating a truly unified design environment. Striking the perfect balance between power and ease of use, Altium Designer has secured its position as the most widely-used PCB design solution on the market.

Now I will show you how I designed the PCB for this project using Altium Designer. I started with making the schematic for the project. Altium Designer has built-in libraries with basic electronic components, but even better you can search for components directly from manufacturers which makes sourcing components for your project very convenient.

Working in Altium Designier - Arduino Air Quality Circuit Schematic

As an example, I found the Mini USB connector using this Manufacturer Part Search feature. From here you can also easily get access to data related to the components, like 3D models, footprints, dimensions etc.

You can also create your own components libraries. I created most of the components for this project on my own, as I wanted to create my own 3D footprints for each part so that at the end, I would get the whole PCB in 3D. For creating 3D models for the PCB footprints, you can use any CAD software, save the files as .STEP files and import them in Altium Designer.

Making a footprint with a 3D model in Altium Designer

Once I finished the schematic, I generated the PCB. I arranged the components as I wanted, and with just a simple click using the Auto Route feature, the software generated all traces automatically.

Making a custom PCB for the Arduino Air Quality Monitor using Altium Designer

If needed, we can manually create or adjust them. Also, we can set design rules how the auto routing will make the traces, set different widths for each net and so on. At this point we also see the PCB in 3D and export a 3D file of the entire PCB assembly which will be used for designing a case for it later on.

Nevertheless, I would like to thanks Altium for sponsoring educational content like this. If you would like to find out more about this software and also try it out, you can check out the links below. You can also try the web based Altium 365 viewer for project previews and file.

Altium Designer free trial – https://www.altium.com/yt/howtomechatronics
Altium 365 viewer: https://www.altium.com/viewer

Here are the Altium Designer project files:

Altium Designer files including the project file, libraries and .STEP files of the 3D models of the electronics components:

PCB Gerber file:

Ok, so once I finished the PCB, I generated the Gerber and the NC Drill files, put them into a single zip file, and so I was ready to order the PCB to be manufactured.

Generating a Gerber files using Altium Designer

I ordered the PCB from JCLPCB. Here we can simply drag and drop the zip file and once uploaded we will get all visual information about our PCB.

Ordering the PCB from JLCPCB

Then we can select the properties that we want and order our PCB at a reasonable price.

Assembling the PCB

After several days the PCBs have arrived. The quality of the PCB is great and everything is exactly the same as in the design.

Arduino Air Quality Monitor Custom designed PCB

So, now we are ready to start assembling the PCB. I started by inserting and soldering the smaller components first, the resistors and the two transistors.

Then we can solder the Arduino Pro Mini board in place. However, first we need to solder the pin headers to it. Please note that we don’t need all its pins, but make sure you don’t miss the one we need like the A4, A5 and the DTR pin. Also make sure you have this exact same Arduino Pro Mini board with this layout of pins, because they can sometimes be different.

Assembiling the PCB - DIY Air Quality Monitor

Next, we can insert the DHT22 sensor in place. For that purpose, first we need to bend its pins 90 degrees. Sometimes I also use Blu-tack adhesive for keeping the components in place when soldering.

The two capacitors used in this project are for stabilizing the power supply. The power to the board will come from a mini-USB connector to which we can connect 5V.

Powering the Arduino Air Quality Monitor via Mini USB connector

Right above the power supply connector we need to solder the two switches. One is for turning on and off the device, and the other is used when we want to upload a sketch to the Arduino board. Then we can insert the pin headers for the USB to UART interface, the display and the PM2.5 sensor, as well as the VOC, the Ozone and the CO2 sensors in place.

Next, for soldering the DS3231 Real Time Clock module again, first we need to bend the pins 90 degrees. Once soldered we can insert the battery which keeps track of the time even when main PCB loses power. With this the PCB is actually done, and what’s left to do now is to prepare the cables that we will use for connecting the PM2.5 sensor and the display to the PCB. I soldered male pin headers to the cable that comes with the sensor, and so I was able to easily connect it to the PCB. For connecting the display to the PCB, I soldered four wires to the back side of the display connector and then connected them to the PCB.

And that’s it, our Air Quality Monitor is actually done. Of course, what we need to do now is to make some kind of box or case for it. As we have the 3D model of the entire PCB assembly from Altium Designer, we can import it in a CAD software and design a case for it.

3D model of the Air Quality Monitor in Solidworks

I used SOLIDWORKS for that purpose, and made the simplest case possible consisting of just two parts and few bolts and nuts. I decided to make the case using transparent acrylic because I like how the PCB and the components look exposed and it’s also a great way to show off your DIY project.

Here you can download the 3D model of the DYI Air Quality Monitor:


STEP file:


Making the Case for the Air Quality Monitor

The acrylic that I will use is 4mm tick which perfectly fit with the display. As I currently don’t have a CNC machine, I cut the shapes manually using a simple metal hacksaw.

Making a case for the arduino air quality monitor with acrylic

For making the opening for display, first I made two holes with a drill. Then I passed through a blade from a mini hacksaw and carefully cut the shape. Using a simple rasp, I smoothed out shape. Then using a 3mm drill I made all the holes for attaching the PCBs and connecting the two acrylic plates together. 

At this point, I removed the protective foil from the acrylic which, and to be honest, that’s quite satisfying process. For attaching the PCB to the base plate, I used some M3 bolts and nuts. For attaching the PM2.5 sensor to the plate we need M2 bolts.  

Next, using some distance nuts we can join the two plates together. By using one female and one male distance nut I was able to easily get the desired distance between the two plates.

I personally really like how this case turned out, plus, it’s functional as air can easily circulate around the sensors. 


All right, so now we can power up the device and upload the program. We can power the air quality monitor through the Mini USB connector and we can get the 5 volts from a 5V USB adapter, a 5V phone charger or a power bank.

Programming the Arduino Air Quality Monitor - Uploading a sketch using a FTDI

For uploading the program to the Arduino Pro Mini board, we need an USB to serial UART interface which can be connected to the programming header. Before connecting it to the computer USB, first we must turn on main power of the device, because otherwise the power coming from the computer USB which is only 500mA might not be enough to work properly. When uploading the Arduino sketch, we also need to switch the upload switch on the PCB.

Here you can download the Arduino Code and the Nextion Display Program:

For uploading a sketch to an Arduino Pro Mini board, in the Arduino IDE first we need to select this board, select the proper version of the processor, select the port and select the programming method to “USBasp”.

How To Upload code to Aduino Pro Mini Board using FTDI

Once we upload the code to the Arduino, we also need to upload a code to the Nextion display. Nextion displays have built-in ARM controller which actually controls the display on its own.

Making a GUI for the Air Quality Monitor using the Nextion editor

All graphics like buttons, text, images, variables and so on, are generated and controlled by the display itself. The Nextion display has a dedicated Nextion editor where we can create all these stuffs. The display and the Arduino communication with just two wires using the serial communication. The Arduino simply just sends the values from the sensor to the display and vice versa, the display sends data to the Arduino when needed. 

For uploading the display program, we need a microSD card where we can save the output .TFT file from the Nextion editor.

Uploading the program to the Nextion display using a microSD card

The display has a card reader where we can insert the microSD card while the power is off. Then we can power up the device and the program will be uploaded to the display. Now we just have to remove the card, switch on the power again, and our air quality monitor will start working. 

Warming up - burning in the sensors when starting the air quality monitor

Code explanation

So, we are using libraries for each sensor and which can be found on the following links, MHZ19, PMS, MQ131, DHT, DS3231. In order to better understand how we read the data from each sensor I recommend reading the libraries documentations and try out their examples.

We are also using the SoftwareSerial library because both the MH-Z19 and the PMS5003 sensors use the serial communication. The Arduino and the Nextion display also use the serial port for communication and in this case we are using the default, hardware serial.

Arduino Air Quality Monitor Program - How It Works

So, the Arduino reads the sensors and sends that data to the Nextion display. Here’s an example.


So we have a variable at the nextion display called “tempV” and in order to update it’s value we need to send a command to the nextion as following “tempV.val=22”. So the variable name, then “.val”, then the value, let’s say 22. The first two lines of the code do that, and in order the Nextion display to accept this command or actually any command we need to send the three unique “write” commands.

In the Nextion display program, we have a timer which runs in a loop, just like the Arduino code loop, and it constantly updates the numbers on the display.

Nextion display timer

In this timer event we also have a code for changing the background color for each sensor depending on its value.

On the second page we have waveform, which gets the values from the stored values from the Arduino. Please note that you can find more info on the Arduino code itself as there is explanation in the comments of the code.

The hours and the Y-axis values also get their values from the Arduino.

On top of the waveform, as well as the numbers on the main screen, you can notice we have like transparent objects, called “Hotstops” in the Nextion editor, and they are act as buttons. If we press the hotstop on the waveform we can see in the Event section that it sends us back to “page 0”.

Overall, that’s how the program of this Arduino air quality monitor works. Of course, in order to fully understand how it works you need to learn and know how each sensor works with their libraries, as well as how the Nextion display works.

Please note that for the VOC sensor we are only reading raw data from this sensor, not ppm or ppb values. Just analog values from 0 to 1024. Higher values means there is a presence of VOC.

As for the Ozone sensor, in order to get more accurate outputs we must set the setTimeToRead()  and setR0() values correctly according to the calibration example of the library. However, longer setTimeToRead means the program will be blocked while sampling and everything else will be freezed.  Of course, there are ways to work this around. I would even suggest not using the ozone sensor at all unless you really need it.

I hope you enjoyed this video and learned something new. If you did please consider supporting me on Patreon. Feel free to ask any question in the comments section below and check my Arduino Projects Collection.

25 Responses

    • Dragomir

      This would be amazing upgrade! Hope that he makes it and add instructions here as well.

    • Ben

      You could if you replace the Arduino with an ESP8266 or ESP32 device. They are Arduino compatible and have built in WiFi. Not sure about the pinouts off the top of my head though.

    • Maciej

      This project is so cool! Any chance for an additional integration with Home Assistant? 🙂

    • Jack

      This project no.
      you can try with esp8266 and arduino framework on it.
      I think with a little work, you can do it.

  1. Wolfgang Rupp

    Hi Dejan,
    nice that you publish a project again, I always wait with excitement for the next projects, I will definitely build your completely new project,
    Please stay healthy
    Greetings Wolfgang Rupp from Germany

  2. Dragomir

    Thank you so much for this article! – It was exactly something I was considering to make in the near future. Few days ago I made a copy of your cnc foam cutter – looking forward to making this project as well!

  3. Bill

    There is a wire missing on the schematic diagram shown above. There should be a connection from pin 6 on the MQ-131 to the A0 input of the Arduino.

    • Dejan

      Well they are indicated with D6 and A0 in the diagram. I didn’t draw all the lines because it would have been a mess and harder to see things.

  4. kirubel yonas

    Hi Dejan,
    I like this project so much even from the Arduino robot arm with smart phone control
    this is my second project or third I think. Can we use NRF24L01 module make it send massage when are away. By the way I’m 13 years old it can crazy. I wish you will answer soonly.With my greeting kirubel.

    • Dejan

      Hey, glad you like it. Well sure you can make any modification, you can use NRF24L01 for wireless transmitting of data.

  5. Andy Monks

    Nice project. Ever thought of changing the arduino pro mini to maybe an ESP32?

    Then you could ditch the rtc, the switches and usb connector. It would also probably be faster at refreshing the data and also have wifi (so ntp time and you could upload data somewhere).

  6. ed Brisebois


    Nice project.

    The Amazon link for the arduino pro mini is different.
    The banggood version looks correct.

    • Dejan

      Hey, thanks! Well yeah, that one is a bit different, but you can still use it as the pins that we need and use in this project are all on the same place.

  7. Ken Barbee

    Hi Dejan,
    Great project. I have everything on order except the passive components. I cannot locate a complete bill of materials on this project page. Capacitor values, resistors, transistors, header pins, switches and usb connector. Can you please point me to the complete BOM?

    Thanks! Cant wait to assemble and start using this!

  8. thefery

    Hi Dejan!
    Awesome project, thank you!
    Could you help me understand why you used two transistors in the project? How do they activate the sensor heater?
    Why out of the RX signal of the PMS5003 PM Sensor there are two resistors, 1K and 2K, but the RX seems to pass only out of the 1K resistor, is it the 2K a pull-down resistor?
    Thank you for your help!

    • Dejan

      Hey, thanks! The resistors for activating the heaters of the two sensors (connected to the base of the transistors) are used for limiting the transistor base current. On the other hand, the two resistors at the PMS5003 Sensor are used as voltage divider. The PM sensor RX pin operate at 3.3V, so with the two resistors we make a voltage divider which drops the 5V coming from the Arduino to 3.3V.

  9. Ian Postlethwaite

    Great project. But your download links do not seem to be working. Specifically the Arduino code, the Solidworks file and the Altium Designer files. All I get with each of them is a 4k invalid .RAR file. Your help would be appreciated as I have just finished ordering all the parts and sensors for my build.

    • Dejan

      Hey, thanks! Try to use different web browser to download the files. I’ve just checked and they work fine.

  10. Christian R.

    Hi Dejan,
    nice project. It captivaded me right away and I wanted to give it a try and build it. The thing is, I´m quite new and inexperienced with electronics and I have some questions.
    What kind of capasitors are needed? I can read the value of the resistors and transistors but not of the capasitors.
    I´m in the procces of gathering all the needed parts and would come back to you, if I have some other questions, if you´re ok with it.

    Best regards and thank you for this very usefull and intresting project,

    • Dejan

      Hey, glad to hear it, thanks! I updated the article in the parts list section, please check it out now. I hope you will have fun building one. As for the electronics, I think you should be fine as if you connect everything as explained everything will be fine. On the other hand, keep it in mind that it can be a bit hard to understand how everything works, especially the programing part, as to be honest it’s actually not that well optimized. Cheers!


Leave a Reply

Your email address will not be published.


Best Entry Level Oscilloscopes for Beginners and Hobbyists 2019



The 8 Best Arduino Starter Kits For Beginners in 2019



Best 3D Printers for Beginners and Hobbyists - 3D Printing