ESP32 Air Quality Monitor

Keep track of air quality with pretty graphs

Similar projects worth following
These are my prototypes of an IOT air quality monitor primarily based on the ESP32 and CCS811 sensor. They're meant for indoor use.

They are not the prettiest at the moment, but they work surprisingly well and run stable.

Video showcase

General specifications:

  • CO2 measuring range: 400-8192 PPM
  • 12 hours of battery life provided by a 18560 cell
  • Pretty graphs on a web interface
  • Data can be exported to Excel and software alike

Breaking it down

The build:

I bought a cheap plastic box on Aliexpress for this project. I drilled some holes on the front for screws, LED's, the button and made some space for the screen. On the back, I've made space for a power cord and an on/off rocker switch.

Inside the unit, there's a small fan running in ten-second intervals for refreshing air inside to get better measurements.

The box ended up being a bit large for the project. When I ordered all the parts I had planned to use an Arduino MEGA as well but ended being able to use the ESP32 for everything. But with all the clutter, fan, battery, screen, etc. it's not that oversized.

What it measures:

  • TVOC - CCS811
  • CO2 - CCS811
  • Temperature - BMP280
  • Atmospheric pressure - BMP280

Most data points here should explain themselves. But some people might be unfamiliar with TVOC. Total volatile organic compounds is a group of different molecules like alcohols, aldehydes, ketones, organic acids, amines, aliphatic and aromatic hydrocarbons. 

The CCS811 doesn't actually claim to measure CO2. Instead, it measures something called eCO2. It's a calculated number, not the actual amount of CO2. But because there is a very tight correlation between TVOC's and CO2 that's no problem for measuring air quality, and it works wonders for the job.

You could actually argue that it's a better way of doing it, in terms of measuring air quality because TVOC's are a better measurement for air quality.

While testing I have made some different observations that affect the measurement if the source is relatively close.

  • Opening a coke - if opened closely it will affect the reading.
  • Taking shoes off - if your shoes smell after a long day it will show up.
  • Spray deodorants - if you apply spray deodorant, then you should probably not do so near this.

Others more obvious observations include painting, cleaning products and so on...

Web interface:

The ESP hosts a web interface providing:

  • Real-time data
  • 24 hours graphs for temperature and CO2
  • Downloadable log
  • Remote restart 

The website's code is embedded in the Arduino code. When someone enters the website data for the graphs will be injected into some Javascript in the HTML code. The code for the graphs is not stored locally, as it would take up too much space. I'm using this wonderful open source library "chart.js".

Calibration and precision:

As of now, I've made four units. Running them close to each other for some time they even out up to 100 PPM CO2 difference. This is more than enough precision for this purpose. But I've tested them up against a professional CO2 monitor as well with similar accuracy. And of course, they've been tested against fresh air which is somewhere between 350 and 400 PPM CO2.


When you first power on the device, it will try to connect to the last WiFi. If that times out after a minute, it will power on an AP called "AirMonSetup" and display an IP address. Simply connect to the AP and go to the IP and you will be guided by an intuitive WiFi connecting interface (largely thanks to the WiFiManager.h library!).

After connecting it will take some minutes for the sensor to warm up. This process usually only takes 10 minutes, despite the datasheet claiming 20 minutes. But this is no worry since it's made for 24/7 operation so it won't be restarted often.

The CCS811 will also require a burn-in first time it's used. This can take a couple of days before reliable data starts showing.

Normal operation:

During normal operation, a new data entry is saved every second logging the previously mentioned data points...

Read more »

Silkscreen mask.xcf

This is a GIMP file for the silkscreen mask.

xcf - 113.77 kB - 04/03/2019 at 10:25


  • 1 × Espressif Systems ESP32
  • 1 × CJMCU-811 CCS811 Air quality sensor
  • 1 × 5mm Red, yellow and green LEDs
  • 1 × TP4056 lithium battery protection and charging circuit Generic China. This model includes several protection features.
  • 1 × 5V micro SD reader Generic China. Modded to work on 3.3v

View all 17 components

View project log

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates