Raise the perfect bread, brew beautiful beer, and rear happy chicks with an Arduino temperature controller. This is particularly useful if you live in a less than reliable climate where directions to keep something at a set temperature aren't particularly helpful. If you are looking for an expensive solution to temperature control, then an Arduino is the way to go.

In this article, we'll show you how to make your own Arduino temperature controller.

Arduino Temperature Controller

Not everybody has an air conditioner, and raising the thermostat for the whole house isn't practical for just making one loaf of bread. Even when kept inside, baby chicks can die if the temperature drops at night; and getting them to hatch in the first place requires an even stricter temperature range. If you are making bread or perhaps raising chicks, avoid purchasing expensive equipment by making a temperature controller with an Arduino and household bits.

The same is also true for keeping items cool. It can be wasteful to power a whole fridge just for making yogurt – 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 from Spark Fun, but of course, the logic will be reversed.

What You Will Need

This is an Arduino project that requires some knowledge of electronics. If you've never worked with Arduino before, you can check out our article explaining what is Arduino and what can you do with it? Otherwise, let's start with what you will need:

  • An Arduino
  • A temperature sensor (such as the TMP36 in the SparkFun beginner's kit)
  • Relay or RC plug switches
  • Screw terminals
  • A Box to trap the heat
  • A heating element or incandescent bulb/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, this will probably be the easiest to set up.

A heating band is used in this tutorial. It's basically a band of rubber that gets warm when electricity is passed through, and it's 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 we advise not to use this unless you are familiar with this material. You can also buy heating pads for the same purpose.

An image of a three-pin temperature sensor. From left to right, an arrow pointing in at the first pin with the caption '2.7-5.5V in'; an arrow point out from the middle pin with the caption 'analog voltage out'; and an arrow point in at the right pin with the caption 'Ground'

For safety reasons, RC plugs are being used to switch AC devices.

Temperature Sensing

Let's start by wiring up and testing the temperature sensor. You can find detailed information about this sensor on Adafruit.

With the flat side toward you and legs face down, the TMP36 temperature sensor is wired up in the order: +, signal, and GND. The + goes to the 3.3V output from Arduino; you also need another line going from the +3.3V to the AREF pin. This will tell the Arduino to use 3.3V for analog input reference instead of 5V. Connect the signal pin of the sensor to A1. In previous attempts, TMP36 was used directly on the 5V line; it works, but unfortunately, when paired with a relay there was a power drop whenever the relay was activated, resulting in readings that highly fluctuated.

For this project we used an old network cable as a signal cable, this is very useful to have around as there are eight wires inside. The cable is quite thin, however, so be sure to strengthen the other end with solder where it'll be screwed into a terminal block.

A hand holding an exposed wire next to a soldering iron station

The formula in the code is correct if you're using the TMP36 sensor; you should be able to find a code sample for other sensors if your model differs. This sample code is from Adafruit, load it up and open the Serial console to examine the output.

tmp36-testing

If possible, you can compare your readings with a thermometer to check the accuracy. Readings not right?

  • Check the voltage being supplied is actually 3.3V
  • Is the AREF connected to 3.3V too?

Adding in Switch Logic

To control the heating element, we've used a couple of RC plug sockets and have taken apart the controller. Only the ground and control pin needs to be connected. The code has been modified to include the relevant libraries which you can download from GitHub.

rc-switches

At this point, you can remove all references to Fahrenheit and continue working with Celsius only if you prefer. Next, define the desired temperature you want to maintain, and add 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);
  }

There's nothing complex here that you won't understand, it's simply 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 copied via Pastebin, though you will need to adjust this if you're using a relay (it's not hard). Here's the complete wiring diagram used:

An arduino wiring diagram for a temperature controller

Putting It All Together

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.

temperature-controller-box

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 the current temperature, allowing you to see the current and desired temperature.

Putting It to the Test

bread-test

Finally, what would this project be without testing our Arduino based temperature controller? Try whipping up a batch of ready-mixed dough and splitting it into two loaves. Put one loaf inside the box and one outside on a bench to see how the results compare. Our tests showed that the loaf inside the box with the temperature control turned out slightly larger.

Wondering what else you can use a temperature sensor for? Check out these projects:

An Inexpensive Arduino Nano Temperature Controller

From precision baking to fermentation stations, an Arduino temperature controller is incredibly handy in a number of different applications. Once you've made this project, you'll be ready to apply this setup to future projects to give you complete control over your experiments!