Introduction: Air Quality Meter


I'm a student at Howest where I study New Media & Communication Technology. For my assignment I created an Air Quality Meter in a couple of weeks.

The meter calculates the temperture, humidity and carbon dioxide en shows the result on a small display. It also collects the data en sends it to a database. I also created a small website which displays all this data in graphs. The database is made in MySQL, the website is written in Flask, and the hardware is attached to a raspberry PI. All my code is also uploaded to my raspberry PI.

In this tutorial I will show you how to create an Air Quality Meter for your own.

Step 1: Bill of Materials

First I'll give you a small list of all the materials I used and the total price. The file is also available.

- wood & tools
- raspberry PI
- mirco SD adapter
- Micro SD card
- T-cobbler plus
- DHT11 (component for calculating temperture & humidity)
- MQ-135 (component for calculating carbon dioxide)
- mcp3008
- 20x4 display
- breadboard wires
- potentiometer

The total costs of all these materials is around 85 euros.

Step 2: Circuit

In the pictures you'll get to see the scheme I created for my Air Quality Meter. It's not a difficult circuit. Be sure to have all these components at hand

- raspberry PI
- T-cobbler plus
- DHT11
- MQ-135
- mcp3008
- 20x4 display
- breadboard wires
- potentiometer
- resistor 10k ohm

Note: The scheme doesn't show that the raspberry PI is connected with the T-cobbler

I'll also put the file of the sheme in here. I created it in a free program called Fritzing
Download link Fritzing

Step 3: Creating a Database

I used a small database to collect the data from the Air Quality Meter and to gather data from the user on my website. The database is created in MySQL. I'll give you the dumpfile. Be sure to connect the database to your flaskproject. Later I'll show you how to put MySQL on your raspberyy PI.


Step 4: Code Project

It's always better to create your own code so you would understand it better. But anyway, I'll give you my code. In order to make it fully work, make sure your database is correctly connected to the flaskproject.

I made code that reads the DHT11 sensor and the MQ135 gas sensor. It also makes sure the data is displayed on the 20x4 display.

note: this code is made for testing the sensors. To connect with the database, put all the code in commentary to useable code

Step 5: Code Website

these are the .py file I used for my website, but for all the templates and staticfiles. I'd like to refer to my githubpage:

Step 6: Raspberry PI

install Flask on the raspberry PI:

check pictures

install MySQL on the raspberry PI:

check pictures

Step 7: Housing

Finally after uploading the code to the raspberry and running it, it should work.

Now we've arrived at the housing of the project.

I sawed 6 sides in wood. the size doesn't really matter, as long as there is enough space to put your project in. It is important however, that you drill a couple of holes so that your sensors can detect the air from the outside (see pictures).
My measurements were 2cm for each hole

You'll also need to drill a hole for the cables of the raspberry.
Don't forget to saw out a piece to make room for the display.
My measurements were 10x4cm.

And that's it!
Now you should have a fully working project!