Make Your Own Temperature Controller With An Arduino
Make Your Own Temperature Controller With An Arduino
Your Own Temperature Controller with an Arduino
Raise the perfect bread, brew beautiful beer, and rear happy chicks with an Arduino temperature controller. If you live in a less than reliable
climate like England, directions that tell you to keep something at a set temperature aren’t particularly helpful – we don’t have air
conditioners, and raising the thermostat for the whole house isn’t practical for just making a loaf of bread. Even kept inside, chicks can die if
the temperature drops at night; and getting them to hatch in the first place has an even stricter temperature range. But I need my bread, and
the chicks need hatching – so instead of purchasing expensive equipment, we can cobble together a competent temperature controller with
an Arduino and household bits.
The same is also true for keeping items cool – it can be wasteful to run a whole fridge just to make yoghurt – but with a temperature
controller, the principle is the same. Instead of activating a heating element, you’ll be activating the plug on a mini-fridge or other cooling
element, like a Peltier (thermoelectric cooler) (https://www.sparkfun.com/products/10080) – and of course, the logic will be reversed.
This is an Arduino project – if you’ve never worked with Arduino before, our free beginner’s guide
(http://www.makeuseof.com/pages/getting-started-with-arduino-a-beginners-guide) is a fantastic place to start.
Arduino
Temperature sensor – I’m using a TMP36, a cheap single package device that comes with the Oomlout
(http://oomlout.co.uk/products/arduino-starter-kit-ardx) (UK) / Sparkfun (https://www.sparkfun.com/products/11576) (US)
beginner’s kit.
Relay or RC plug switches
Screw terminals
Box to trap the heat
Heating element or incandescent bulb and fixture (or both)
The last item has been left deliberately vague. If you have an incandescent bulb (the kind that gets hot, not an energy-saving bulb), or a hot
lamp for sporting injuries and such, it’s probably the easiest to set up. I’m using a heating band – basically a band of rubber that gets warm
when electricity is passed through, used on carboys and kegs for initial fermentation stages in wine or beer making – technically, this can be
a fire risk when not wound around something, so please don’t do this, I’m only using it to test. You can also buy heating pads for the
same purpose.
http://www.makeuseof.com/tag/makeyourowntemperaturecontrollerwithanArduino/ 1/6
20/11/2015 Make Your Own Temperature Controller with an Arduino
Temperature Sensing
Let’s start by wiring up and testing the sensor. [Diagram from Adafruit (http://learn.adafruit.com/tmp36-temperature-sensor)]
With the flat side toward you and legs face down, the TMP36 temperature sensor is wired up +, signal, GND in that order. The + goes to the
3.3 V output from Arduino; you also need another line going from the +3.3 V to the AREF pin – this tells the Arduino to use 3.3 V for analog
input reference instead of 5 V. Connect the signal pin of the sensor to A1. In previous attempts, I had used the TMP36 directly on the 5 V
line; it works, bit unfortunately when paired with a relay, there was a power drop whenever the relay was activated, resulting in highly
fluctuating readings.
I used an old network cable as signal cable – very useful to have around, since there are 8 wires inside. The cable is quite thin though, so be
sure to strengthen the other end with solder where it’ll be screwed into a terminal block.
The formula in the code assumes you’re using the tMP36 sensor; you should be able to find a code sample for other sensors. This sample
code is from Adafruit (http://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor) – load it up and open the Serial console to
examine the output.
http://www.makeuseof.com/tag/makeyourowntemperaturecontrollerwithanArduino/ 2/6
20/11/2015 Make Your Own Temperature Controller with an Arduino
To control the heating element, I’m using these RC plug sockets from Maplin, and have taken apart the controller. Only the ground and
control pin need be connected. I’ve modified the code to include the relevant libraries which you can download from here
(https://code.google.com/p/rc-switch/).
At this point, I’m also going to remove all references to Farenheit and continue working with Celsius only. I’ve then defined a desired
temperature to maintain, and added in a simple control structure like so:
if(temperatureC < desiredTempC){
mySwitch.switchOn(1,1);
Serial.println("Heater ON");
}
else{
Serial.println("Heater OFF");
mySwitch.switchOff(1,1);
}
http://www.makeuseof.com/tag/makeyourowntemperaturecontrollerwithanArduino/ 3/6
20/11/2015 Make Your Own Temperature Controller with an Arduino
There’s nothing complex here that you won’t understand – just comparing the current temperature reading to the desired one, and turning
on the switch if it’s lower; otherwise, turn it off.
The complete code can be found here (http://pastebin.com/Gb03k3Tf), though you will need to adjust this if you’re using a relay (it’s not
hard). Here’s the complete wiring diagram I used:
Tape the sensor inside the box you’re using, and place the heating element wherever is appropriate. Set the desired temperature, and turn it
all on. If you keep your PC connected for now, you can use the Serial console to observe changes as your box heats up.
Further Work
To lessen the impact of any temperature fluctuations, you can try smoothing the results. Create an array to store 10
http://www.makeuseof.com/tag/makeyourowntemperaturecontrollerwithanArduino/ 4/6
20/11/2015 Make Your Own Temperature Controller with an Arduino
Finally, what would this project be without a little test? I whipped up a batch of ready-mixed dough in the bread machine and split it into two
loaves. The one leavened inside the box was mildy bigger, but then the ambient air temperature today is about 26 degrees Celsius anyway –
this would be much more useful in winter. Regardless, I better go make some soup to accompany this lovely bread.
Image credit: Ian Watkins/flickr (http://www.flickr.com/photos/ianwatkins/2085508042/)
Raspberry Pi (http://ww… Join DIY Tech Projects Join Arduino Projects Join
177 Members 152 Members 128 Members
(http://grou.vi/qo) (http://grou.vi/oo) (http://grou.vi/so)
http://www.makeuseof.com/tag/makeyourowntemperaturecontrollerwithanArduino/ 5/6
20/11/2015 Make Your Own Temperature Controller with an Arduino
http://www.makeuseof.com/tag/makeyourowntemperaturecontrollerwithanArduino/ 6/6