For this project. I used a raspberry pi to monitor air quality in an indoor room. It also has a relay wich controls a plug on the back. With this plug you can control a ventilator or other devices. It is made out of wood and you can see the values of the sensors on a site powered by flask.it can measure CO2, humidity, temperature and CO or no CO. The monitor has to be on for around an hour to give the right values.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Building Materials
- raspberry-pi 3
- 3 x 330 ohm resistors
- a plug from a computer (optional)
- a 4-position switch
- a mg811 CO2 sensor
- 1602A display
- mq-7 CO sensor
- DHT-22 temperature and humidity sensor
- IC foot
- 2 x relay module
- a 2 position switch
- a wall plug
- a 5 volt ventilator
- a print
- a 10k potentiometer
- jumper cables
- 3-way plug
- 5V adapter
Step 2: Wiring of the Components
First connect all the components on a breadbord like you see on the picture.
- switch pin one -> gpio 18
- switch pin two -> gpio 23
- switch pin three-> gpio 24
- switch pin four-> gpio 25
- relay1 ->gpio 12
- relay2-> gpio 17
- RS-> gpio 16
- RW->gpio 20
- E->gpio 21
- D4-> gpio 6
- D5-> gpio 13
- D6-> gpio 19
- D7-> gpio 26
- DHT-22-> gpio 22
- CO-> gpio 5
Step 3: Setting Up the Pi
First you need to do the basic setup of the pi. You need to have the latest version of debian installed. You can install the newest version by connecting with the pi with ssh. Then connect the pi with the internet and type 'sudo apt-get update && sudo apt-get upgrade' in the console.
Then we need to install mysql. we do this by typing 'sudo apt-get install mysql-server' and
'sudo apt-get install mysql-client'.
Then we install mysql-connector on the raspberry pi, we do this by typing 'sudo apt-get install python3-mysql.connector' in the console.
Step 4: DHT Library
For the DHT-22 humidity and temperature sensor a library is needed to read the values.
To install the dht library folow the next steps from this site: .http://www.knight-of-pi.org/measure-temperature-and-humidity-with-the-sensor-dht22-am2302/
Step 5: The Database
For the database we use mysql.
Import the following sql file in your database on your pi to store all the values you measure with the sensors.
It is also important that you dont work with the root user of your mysql database. I also made an ERD for the structure of the database, you can see this in the picture. You can also see all the tables of the database in the pictures.
Step 6: The Code
You can download the code at this link:https: //github.com/TiboVandemoortele/AirChecker.
All the files are supposed to be placed in the map /home/pi/airchecker .
To make sure that the files run in the startup you need to go to the console and type "cd /etc".
Then type "sudo nano rc.local" it should open a file that looks like the picture above. If the file is opened you need to add the two new lines displayed in the other picture.
Step 7: The Case
To make the case i mostly used materials that i had at home.
For the biggest part i used wood because it is easy to work with and it has a nice color. For the front plate i used a recyled plastic plate material.
My case is 380x150x170 mm.
The sideplates are 150x150 mm, the ground plate is 340x90 mm, the back plate is 340x150 mm, the piece to fill the gap is 80x150mm and the top plate is 380x150.
In the top piece,the side pieces and the bottom piece i made a gap where the front plate can slide in. Then i made a hole in the bottom plate for the ventilator with a clock drill and drilled a few holes to set the components in place with screws.
For the back piece i used a fretsaw to saw out the piece for the computer plug an the side piece where the adapter for the raspberry pi needs to be. I also made a gap where the flat cable of the raspberry pi could go in to connect it to the T-cobbler. For the hole for the wall plug i first drilled 4 holes and then sawed out the piece. Then i glued the side pieces to the bottom piece and wated for a day. When it was dry i screwed the back piece to the bottom plate and attached the first pieces like you see in the picture.
Step 8: The Pcb
After i made the case i soldered my pcb lik you see in the picture. I placed the lcd display to the front and all the other components on the back.
Step 9: Assembling the Unit and Making the Front Plate.
Once the pcb was made i sawed a hole in the front plate for the display and drilled another 3 holes in the front plate for the potentiometer, the flip switch and the 4-way switch. Then i drilled another 3 holes to attach the pcb to the front plate. Once i made the front plate i attached the sensors to the frame in front of the raster so fresh air could reach them. Then i attached the top plate. I also attached the piece to cover the piece on the back that is sawed out for the adapter of the raspberry pi.
Step 10: Finishing.
To finish the project i put knobs on the potentiometer and the 4-way switch. I also put black shells on the screws and i put 4 stickers for the 4 states of the 4-way switch.