Console Cooler
Do you have an old console?
Are you afraid that your console might overheat during the summer?
Then this is the project for you!
My name is Thibeau Deleu and I'm I am a student from Multimedia and Communication Technology at Howest Kortrijk.
The name of this project is called 'Console Cooler'. As the name says, its a device that helps you keep your console cool! The cooling happens through a fan on top of the case, which creates an extra air stream.
This project is for people who have an old console that heats up quite fast, especially during the summer. You will also be able to see the status of the console on a (self made) site.
The Main Components (sensors and LCD)
What exactly do we need to build this device?
Lets start by giving an overview of what the main components are:
- LDR Resistor
- ML35 temperature sensor
- Jtron DC 5V 0.23a 3 5 cm Cooling Fan.
- PIR Motion sensor
- Ultra Sonic sensor
For the question of the beginning of this step, I'll place 2 excel pictures with all the components you need. But I'll cover the most important parts in the following steps, so it'll be easier to understand.
First of all, we need the main component to make this work and that is the Raspberry Pi with at least a 16GB micro SD card. Without it, nothing works.
Second are the components which will register the important parameters to see the temperature inside the case and the status of the console.
For this we need a temperature sensor and a light sensor. The ones I'll use in this project are:
- LDR resistor
- LM35 temperature sensor
As for the fan itself, I'll use a Jtron DC 5V 0.23a 3 5 cm Cooling Fan.
There are some extra components on this project, because it was interesting to add them to the project (for me personally).
The first component is a PIR Motion sensor which will work as a button to activate te fan. The second component is an ultra sonic sensor to measure the distance between the case and the wall. I implemented this last sensor, because it's important that the air can escape the case easily.
At last we have a LCD to show the IP adres of the site.This site will show the values of the sensors and you'll be able to control the fan from this site.
The Items to Make the Circuit Work (transsistors, Resistors, ...)
The following transistors / resistors were used to make this project work.
Transistors:
- NPN transistor: PN2222 (1 needed)
Resistors:
- 10k ohm (3 needed)
- 1k ohm (2 needed)
- 2k ohm (2 needed)
Powersupply:
- Breadboard powermodule 3V / 5V (1 needed)
Cables:
- male/male (at least 30-40)
- female/male cables (around 10-20 for LCD, LDR and fan)
- female/female cables (around 10-20 if you want to extend some cables for the case).
Other:
- 1 Potentiometer (for light regulation on the LCD)
- 1 MCP3008 (to convert analog value LDR to digital value)
- 2 breadboards to place everything on.
The Wiring Schematic With Explanations
This step is an extension of the previous. Here I'll show the complete electrical wiring schematic for making the console cooler. Please click on the attached files to see how to connect everything.
The Case: Components
Of course, this electrical circuit needs to be protected from different forces which may cause it to stop functioning. With forces i mean things like the rain, objects which might hit the device etc.
For this reason a case is necessary.
To create this case, we need the following components:
Wood:
- One big fiberboard (1.2 cm thick) to cut the following pieces:
- 2 pieces of 14 cm on 20 cm (front / back of the case)
- 2 pieces of 45 cm on 12 cm (sides of the case)
- 2 pieces of 20 cm on 45 cm (top / bottom of the case)
- 2 bars (to use as feet for the case)
Hinges:
- 2 hinges to open the front (the hinges are on the bottom of the front)
- 2 hinges to open the top
Handle:
- 1 handle (to open the front)
Glue:
- 1 big tube of TEC glue (to glue the pieces together)
Saw:
- Atlantic Saw (to cut the necessary holes in the pieces for the sensors, LDR and fan)
Sander:
- Black&Decker to smoothen the pieces once they are cut
Drill:
- 1 drill with a screw diameter of 0.6 cm (to create the holes)
Paint / Primer:
- 1 pot of white Levis primer (0.25L)
- 1 pot of white Levis paint (0.25L)
Magnets:
- 2 magnets (which will hold the door of the case)
Brushes:
- 1 roller (to paint the bigger surfaces)
- 1 brush (for the details)
Screws:
- 8 small screws for the hinges (max 1.1 cm long, since the plate is 1.2 cm thick)
- 2 small screws for the handle (max 1.1 cm long)
- 4 small screws for the magnets (max 1.1 cm long)
The Case: Creation
Now it's time to make the case.
- For the top piece of the case. Cut the plate in half, because the back half needs to be opened so we can get to the sensors/electronics
- Cut the following holes in the fiberboard pieces
- On the top front half piece. Cut 3 holes:
- 1 rectangle hole (6.8 cm on 3.5cm for the LCD)
- 1 circle hole (diameter of 2.5 cm for the fan)
- 1 square hole (2.5cm on 2.5 cm for the PIR motion sensor)
- Cut in the back piece a hole in the form of a circle. This is where the power cables will come through.
- Drill small holes with the drill with a screw of 0.6 cm diameter on the back (around de hole for the cables) and the left side of the case. We do this so there will be enough air circulation in the case.
- On the right side of the case. Cut a hole in the back (5.5 cm on 3.5 cm) for the Ultra sonic sensor (so it can work properly).
- Glue all the pieces together with the TEQ glue. If necessary, you can add fiberboard bars to strengthen the sides of the case. Place these bars inside the case.
AFTER EVERYTHING HAS DRIED
- Screw the handle on the front of the case. Screw it on the top of the front piece (NOT the top piece where we made the 3 holes => see the pictures for clarification if necessary).
- Screw 2 hinges (4 screws) on the right side (in the back) of the case so that the top back half can be opened.
- Screw 2 hinges (4 screws) on the bottom of the front piece so that the front side of the case can be opened.
- Screw the magnets on the inside of the case:
- 2 magnets in front of the top front piece inside- 1 metal piece on top of the front piece so it connects with the magnets
-
Glue the fiberboard bars on the bottom of the case so that the front can be opened easily with the handle.
- Add primer to the case
- Add white paint to the case
- Congratulations! Your case is done!
Placing the Components in the Case
For the placement of the components in the case, the following:
- The LCD and Fan will be screwed on top of the case one the OUTSIDE.
- The PIR motion sensor wilt be glued on top of the case on the INSIDE.
The reason why we do this for the motion sensor and not the rest, is to prevent the motion sensor from non stop registering.
The breadboards (with most of the electronics on it) will be glued inside the case and are placed in the back. Pay attention that de Ultra sonic sensor is visible through the hole on the right side.
The Raspberry Pi will be placed in the front half of the case. Since the Pi is the console that needs to be cooled, it doesn't need to be glued/screwed (since we wouldn't do that with a real console).
Setup Raspberry
Before we start coding, we need to setup the right environment.
How do we do that? By downloading the raspbian buster image for the raspberry pi and to write it on the raspberry by using Win 32 disk imager. Before you start te write te image to the Pi, make sure to create an SSH-file (without an extension) in the image to enable SSH on the Raspberry Pi .
Setup on the pi
After you've done this, you can use putty to login on your raspberry so you can configure it properly. Be aware that you'll need to connect your Pi to your pc with a ethernet cable.
The default user and password for the Pi are the following:
user: pi
password: raspberry
You can change this using raspi-config.
We must add a network on your Pi so that other devices can look at your site when they are on the same network.
Enter the following commands on putty.
- sudo iw dev wlan0 scan | grep SSID
- wpa_passphrase "NAMEOFYOURNETWORK"
- Enter the password of your network
- sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
- sudo reboot
- ifconfig (to check of your wifi setup worked)
You will have to make sure your Pi is up to date by using the following commands while the Pi is connected to the internet:
- sudo apt-get update
- sudo apt-get upgrade
After which you can enable or install the packages for the project to work, either through raspi-config or commands. Since we're talking about raspi-config, we can enable the one-wire interfacing here so that the raspberry can read the one wire sensor. Go to the interfacing options, select one wire and press enable. You'll also need to install SocketIO with:
- pip install flask-socketio
Now that we have internet, we need to create our database. But first we need to download MariaDB (on the pi) and Mysql Workbench (on the pc) so we can work on MariaDB.
Setup Pc
Mysql Workbench
After everything is installed, we can acces MariaDB through Mysql Workbench on our pc.
When we create a new database, we need to configure this database like the image above (the one with connection name 'raspi'). While we are configuring this database, we need the username / password of both the database and the raspberry. the default user and password are 'mysql' / 'mysql' on the database and 'pi' / 'rapsberry' on the Pi.
If there is a connection warning, you can just press 'Continue anyway'
Visual Studio Code
The other software we need is Visual Studio Code.
Once installed you need to install the following extension.
This extension allows you to write your pi programs on your pc. When this is installed, do the following:
- Press F1 en type SSH
- Pick remote acces: add new SSH host
- Enter the following data
- ssh 169.254.10.1 -A
- Press enter
After this you'll be connected to your raspberry pi.
The last thing we need, is to install the python extension on the remote machine. Without this, we cannot run the programs we write on our pc.
Let the Coding Begin
Now that the hardware is ready, it's time to start with the software.
Before we start, we'll start to add some structure for our files. In this case, we'll create a folder for the front end, back end and the database. There will be a link to my Git Repository (in the following steps) with all the files if this seems confusing. You can just take over the files from there if necessary.
Now that we have some structure, I'll give a short overview on how the coding will proceed.
1. Database creation
When we want to create a database for the values of our sensors, we'll need a good model to store our data. Once we have this model we can forward engineer this model to create our database. To create the model we'll work on Mysql Workbench, please check the image in this step to see how the model looks like.
to create a model / forward engineer do the following:
- To create a model press file (left on top)
- Press new model
- For further information, press the following link
- For forward engineering, press model
- Press forward engineer
- Press yes/continue until the end of the process.
2. Back end
The back end will be the place where the coding will be for all the devices and sensors. It will be split between helper classes which will contain the code for the components and the main code (app.py) where everything comes together.
The database files will also be in this folder since the back end gets the info from the database through the datarepository.py file in the repository folder. The config.py file is purely to connect the backend to the database.
3. Front end
The front end is for the site. This folder will contain the HTML/CSS/JAVA code. The site should be available through the IP from your Rapsberry Pi. So if your pi has the following IP: 192.168.0.120, then you can visit your site through this IP-address. If you want to know the IP of your pi, you can enter 'ip a' in putty and look at the WLAN0 address.
Backend
As mentioned in the previous step, the back end is where all the code is written for the components. What I didn't mention was how to get the data from the database and how to send it to the front end of our site.
The following steps should be done in order to do this:
- Create mysql queries to get/update/insert data to your database. The file which contains these queries is the Datarepository.py file.
The database.py file is the file which will communicatie with the database and will use the queries from the datarepository.py to get the data you want.
To make sure you can connect to your database, please make sure that the config file has the same password / user as your database. Also make sure that the right database is selected. - Once we can communicatie with the database, we need to create a route (app.route(endpoint...)). This route is the connection between the front end and the back end. Another connection which can be used is Socketio.
- Make sure to import all the correct libraries (in app.py) to make this project work. You can see the my github, if you want to know what libraries I used for the app.py.
To make sure that the database will be filled with up to date data, its important to do constant readings from the sensors. The best way to do this is through a while-loop and to run this while-loop in a thread. Otherwise your program will be stuck in de while-loop.
Frontend
In the front end there are
3 html pages:
- home.html
- light.html
- temperature.html
3 css files :
- screen.css (which is a file given to me by my school.)
- normalize.css (which helps to implement to css on different browsers.)
- main.css (which contains the main css for the html-pages.)
2 javascript files:
- app.js (which will take the data from the back end and will place it on the front end.)
- datahandler.js (which will handle the data from the backend so that app.js can work with it.)
I'll add the link to my github here as well, just in case.