Sie sind auf Seite 1von 14

DIY

Make Your Own Temperature Controller with an Arduino

By James Bruce / August 30, 2013 / 5 minutes

Facebook Twitter Pinterest Stumbleupon Email

Advertisement

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
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 arent particularly helpful we dont have air conditioners, and raising the thermostat for the
whole house isnt 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, youll be
activating the plug on a mini-fridge or other cooling element, like a Peltier (thermoelectric cooler) and of
course, the logic will be reversed.

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
What You Will Need
This is an Arduino project if youve never worked with Arduino before, our free beginners guide is a
fantastic place to start.

Arduino

Temperature sensor Im using a TMP36, a cheap single package device that comes with the Oomlout
(UK) / Sparkfun (US) beginners 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, its probably the easiest to set up. Im 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 dont do this, Im only using it to test. You can also buy
heating pads for the same purpose.

For safety reasons, Im using these RC plugs to switch AC devices, with a controller hacked apart detailed in
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
this home automation article. Its wireless, so at no point need I actually touch live wires.

Temperature Sensing
Lets start by wiring up and testing the sensor. [Diagram from Adafruit]

Advertisement

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
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 itll be screwed into a
terminal block.

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
The formula in the code assumes youre using the tMP36 sensor; you should be able to find a code sample for
other sensors. This sample code is from Adafruit load it up and open the Serial console to examine the
output.

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Compare with a thermometer if possible. Readings not right?

Check the voltage being supplied is actually 3.3 V

Is the AREF connected to 3.3 V too?

Adding in Switch Logic


To control the heating element, Im using these RC plug sockets from Maplin, and have taken apart the
controller. Only the ground and control pin need be connected. Ive modified the code to include the relevant
libraries which you can download from here.

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
At this point, Im also going to remove all references to Farenheit and continue working with Celsius only. Ive
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);
}
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
}

Theres nothing complex here that you wont understand just comparing the current temperature reading
to the desired one, and turning on the switch if its lower; otherwise, turn it off.

The complete code can be found here, though you will need to adjust this if youre using a relay (its not hard).
Heres the complete wiring diagram I used:

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Putting It All Together
Tape the sensor inside the box youre 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.

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Further Work
To lessen the impact of any temperature fluctuations, you can try smoothing the results. Create an
array to store 10 readings, and calculate an average on each loop.

To avoid rapid activation and deactivation of the heating element, create a variable to store a
countdown. Each time you activate or deactivate, record the current time in the countdown, then
before switching the state again check to see if X amount of time has elapsed since the last state
change.

For a computer-less project, hook up a small LCD screen to display current temperature and allow you
to see the current and desired temperature.

Putting It To The Test


open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
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.

So, what would you make that requires a constant temperature?

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Image credit: Ian Watkins/flickr

3 8 CO MMENTS WR ITE A CO MMENT

Advertisement

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
2017 MakeUseOf. All Rights Reserved.

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com

Das könnte Ihnen auch gefallen