Hagenfaber Airquality
Welcome! For a school project I had to make an air-quality device that measures some values in your room. These values include: Temperature, relative humidity and theCO2 levels. It will then take these values and visualize them on a website using graphs. You will be able to see the live values and also the historic values.
Supplies
There are a couple of materials and devices you will need.
First of all the devices that will make sure you read and write you sensor data to the website.
- Arduino UNO (for reading the sensor data)
- Raspberry PI (for running the website and saving the data)
Second of all you will need some sensors and actuators.
- DS18B20, Digital temperature sensor
- DHT22, Digital temperature and humidity sensor (mainly for the humidity)
- Adafruit CCS811 Air-quality sensor (measures CO2 and TVOC values
- Dekstop 5V fan (to add some life to the device)
- I2C Oled
Last but not least you will need some materials to make everything come together.
- Some jumper wires
- A couple of resistors (2 x 4.7K Ohms, 1 x 220 Ohms)
- Diode 1N4007
- A transistor 2N2222
- Any material to build the case (I used 8mm MDF wood)
- Some nuts and bolts
- Solder materials
- A PCB to solder the sensors to
Build the Circuit
The circuit can be build on a breadboard. But I soldered everything from the breadboard to a PCB. This made the circuit a lot more compact and more of a permanent solution. It made it easier to combine the circuit with a case since I made a 'hat' for the Arduino where you don't need any loose cables. The only cables that are 'loose' are the cables for the OLED screen and the Fan on top which are glued to the lid. One last note is that you need to get some form of serial communication between the 2 devices. I simply used a short USB A to USB B cable. This could also be done with a level shifter but I did not do this because this also added to the circuit and makes things more complex.
Setup the Raspberry Pi
There are a couple of things you need to do before adding the code to the Raspberry Pi.
- Install Raspberry OS on a micro SD card. (more information on this topic here https://projects.raspberrypi.org/en/projects/rasp...)
- Make sure you have a recent Python version including pip (Here you can find a list of programs or services that are most commonly installed on the Raspberry Pi: https://www.pantechsolutions.net/blog/installing-...
- Install the needed Python packages using the command: [TODO]
pip3 install -r requirements.txt
- Copy the code from my github to your home folder at /home/: [TODO] add github repo
- Install the apache2 webserver using:
sudo apt update sudo apt install apache2
- Change the root folder of the apache2 default configuration:
sudo nano /etc/apache2/sites-available/defaultand find this line
DocumentRoot /var/wwwand change it to
DocumentRoot /home///Code/Frontend
- Reload the apache2 service
sudo systemctl reload apache2
- Now we need to make the services for the backend and the sensor code, creating a service is quite simple all you need to do is make a service file
sudo nano /etc/systemd/system/.serviceThis is an example of the Backend code. Do this once for the Backend folder and once for the Pi folder
[Unit] Description= After=network.target [Service] ExecStart=/usr/bin/python3 -u /home/<your_username>/<your_repo>/Code/Backend/app.py WorkingDirectory=/home/<your_username>/<your_repo>/Code/Backend StandardOutput=inherit StandardError=inherit Restart=always User=<your_username> [Install] WantedBy=multi-user.targetstart the service using
sudo systemctl start .service
Your code is now running and you can move on to the next step!
Build the Case
For the case you could actually do what you want. In case you want to recreate it just like I did, here is what i did:
- I build a rectangle out of 8mm MDF wood and glued a top to it.
- I made a plank the exact size of the rectangle and a plank just 8mm smaller that the first plank.
- I drilled some holes in the second (smaller) plank and attached the Raspberry Pi and the Arduino to it.
- Then I attached the smaller plank to the larger plank exactly in the middle.
- Now we need to make cutouts for the fan and for the OLED screen. These size are adjusted to the exact components I used, so if you used some different components you have to make cutouts for those.
- Now all you have to do is build everything together and start the code.
You could also build your own case in case you want different dimension or you want to build a better case.
Questions...
In case you still have questions you can always contact me or leave a comment!