Raspberry Pi Zero W Based Personal Temperature Controller
Introduction: Raspberry Pi Zero W Based Personal Temperature Controller
Space heaters usually come with a thermostat for temperature control. The temperature control is done at the heating device and are might not be where you are located. Also, a lot of the space heaters just have a numbered dial for temperature control and not actual temperature settings. I wanted to be able to detect the surrounding temperature where I am sitting at and use that to control a space heater to warm my surrounding to the desired temperature level. My goal was to have to do a minimum amount of work and at a reasonable cost. Also, I want to be able to see and control things from my mobile phone. The approach I took was to use a Raspberry Pi Zero programmed with Python as the temperature controller and and an off-the-shelf AC power relay to switch the space heater on and off.
Supplies
Here is the list of components that I used (prices are at time of writing and for reference only):
1. Raspberry Pi Zero W ($10) - There is an updated Raspberry Pi Zero 2 W ($15) that can be used as well.
2. Raspberry Pi Zero case ($5.95) - This comes with three different type of cover and a Mini Camera Cable. We will just be using the fully enclosed cover for this.
3. DHT22 temperature sensor ($9.95) - This comes with a 10K ohm resistor that we will need to use.
4. Controllable Four Outlet Power Relay Module ($32.95) - This has an always-on outlet to power the Raspberry Pi Zero W.
5. 16GB Micro SD Card ($7.73) - Can use a 8 GB Micro SD card for this if you have one lying around.
6. 5V power adaptor and micro USB cable - I used one left over from an old Android phone I had. You probably have these 5V power adaptors and micro USB cables lying around. The standard Raspberry Pi Zero W power adaptor is 1.5A but I found that a 5V 1A adaptor worked OK for me.
7. Breadboard Jumper wires ($6.98) - Pack comes with 120 pieces of different jumpers. I used 2 male-to-female and 3 female-to-female Breadboard Jumper Wires.
8. Break-away Male Header ($4.95) - There are 10 pieces of the 36-pin 0.1" Short Break-away Male Header in the package. We plan to break off 6 pins for this. 152
So, if you have these header pins lying around, go ahead and use them.
9. Right angle metal bracket (optional)
10. Space Heater - I used an oil-filled radiator type space heater. Your can choose your own of space heater (the power relay module can switch a heater up to 1440W).
Here are the tools I used:
1. Computer with a SD card reader/writer to prepare and program the Raspberry Pi 2 W
2. HDMI monitor with standard-to-mini HDMI cable (or regular HDMI cable and mini HDMI adaptor)
3. Keyboard and mouse with Micro USB Male to USB Female OTG Adapter and USB Hub
4. Soldering iron and appropriate solder for the soldering iron
5. Hot glue gun and appropriate hot glue
6. Scotch tape
7. Small slotted screw driver
Step 1: Prepare the MicroSD Card
The Raspberry Pi Zero W depends on an operation system (OS) software that will be loaded onto the microSD card to run. Raspberry Pi Imager is the quick and easy way to install Raspberry Pi OS to a microSD card, ready to use with the Raspberry Pi Zero W.
Please go to the official Raspberry Software page to download and install the appropriate Raspberry Pi Imager onto your computer. Make sure you have a microSD card reader on your computer. Once the Raspberry Pi Imager has been installed on your computer, run it. Insert the microSD card into the reader on your computer.
From the Raspberry Pi Imager interface window, click "CHOOSE OS" and from the drop-down menu, select "Raspberry Pi OS (32-bit)". Click "CHOOSE STORAGE" to open up a selection window showing the devices that the Imager can write to. If you have inserted the microSD card, an item with "SD Card - 16GB" (or 8GB, if that is what you inserted) should show up. Select that item. Now, click "WRITE". The Imager will install the Raspberry Pi OS onto the SD card.
After the OS has been installed onto the microSD card, remove it from the reader and and save it for the step when we assemble the Raspberry Pi Zero W board in Step 3. 259