Arduino Temperature Controller

Digital Temperature Controller using arduino, here we are using arduino as main controller, this temperature controller controls the temperature of any heating device with given set points, It also displays state of the device either on or off and current temperature.

As the name implies, a temperature controller is an instrument used to control temperature. The temperature controller takes an input from a temperature sensor and has an output that is connected to a control element such as a heater or fan.

To accurately control process temperature without extensive operator involvement, a temperature control system relies upon a controller, which accepts a temperature sensor such as a thermocouple or RTD and LM35 as input. It compares the actual temperature to the desired control temperature, or set-point, and provides an output to a control element.

What Are the Different Types of Controllers, and How Do They Work?

There are three basic types of controllers: on-off, proportional and PID. Depending upon the system to be controlled, the operator will be able to use one type or another to control the process. In this Arduino example we are making on-off type controller.

On/Off Control

An on-off controller is the simplest form of temperature control device. The output from the device is either on or off, with no middle state. An on-off controller will switch the output only when the temperature crosses the set-point. For heating control, the output is on when the temperature is below the set-point, and off above set-point. Since the temperature crosses the set-point to change the output state, the process temperature will be cycling continually, going from below set-point to above, and back below. In cases where this cycling occurs rapidly, and to prevent damage to relays and valves, an on-off differential, or “hysteresis,” is added to the controller operations. This differential requires that the temperature exceed set-point by a certain amount before the output will turn off or on again. On-off differential prevents the output from “chattering” or making fast, continual switches if the cycling above and below the set-point occurs very rapidly. On-off control is usually used where a precise control is not necessary, in systems which cannot handle having the energy turned on and off frequently, where the mass of the system is so great that temperatures change extremely slowly, or for a temperature alarm. One special type of on-off control used for alarm is a limit controller. This controller uses a latching relay, which must be manually reset, and is used to shut down a process when a certain temperature is reached.

Proportional Control

Proportional controls are designed to eliminate the cycling associated with on-off control. A proportional controller decreases the average power supplied to the heater as the temperature approaches set-point. This has the effect of slowing down the heater so that it will not overshoot the set-point, but will approach the set-point and maintain a stable temperature. This proportioning action can be accomplished by turning the output on and off for short time intervals. This “time proportioning” varies the ratio of “on” time to “off” time to control the temperature. The proportioning action occurs within a “proportional band” around the set-point temperature. Outside this band, the controller functions as an on-off unit, with the output either fully on (below the band) or fully off (above the band). However, within the band, the output is turned on and off in the ratio of the measurement difference from the set-point. At the set-point (the midpoint of the proportional band), the output on:off ratio is 1:1; that is, the on-time and off-time are equal. if the temperature is further from the set-point, the on- and off-times vary in proportion to the temperature difference. If the temperature is below setpoint, the output will be on longer; if the temperature is too high, the output will be off longer.

PID Control

The third controller type provides proportional with integral and derivative control, or PID. This controller combines proportional control with two additional adjustments, which helps the unit automatically compensate for changes in the system. These adjustments, integral and derivative, are expressed in time-based units; they are also referred to by their reciprocals, RESET and RATE, respectively. The proportional, integral and derivative terms must be individually adjusted or “tuned” to a particular system using trial and error. It provides the most accurate and stable control of the three controller types, and is best used in systems which have a relatively small mass, those which react quickly to changes in the energy added to the process. It is recommended in systems where the load changes often and the controller is expected to compensate automatically due to frequent changes in set-point, the amount of energy available, or the mass to be controlled

What you will learn?
  1. How to connect keys and LCD to arduino?
  2. How to take key input?
  3. How to Read Temperature sensor LM35?
  4. Controlling device as per set point.
Components Required
  1. Arduino Uno
  2. 16×2 LCD Display
  3. keys
  4. Relay
  5. 1K Resistors Qty. 3
  6. BC548
  7. LEDs
  8. LM35 Temperature Sensor

Arduino Temperature Controller Circuit

Circuit is constructed using Arduino Uno and LM35 temperature sensor and other components. We are using 16×2 LCD to display current temperature and set points. LM35 gives analog output proportional to the temperature which is given to Arduino analog input A0. Which is then compared with set points if it is more than set point, It means the temperature is more so we turn off the heating element such as heater which is connected to relay output. If temperature is less we turn on the relay (heater). We are displaying status of heater on off on the LED and LCD also. Two tactile switches are used to set the temperature set point.

Arduino Temperature Controller Circuits
Temperature Controller Circuits


Temperature Controller Arduino Code

                Program is constructed using one library “LiquidCrystal”. Program have different modules, Setup, Loop. In setup we initialize all the IO connections and LCD, Keypad. In main loop we are taking set point inputs and constantly measure current temperature and compare it with set points. If it is more than set point turn off heater, else turn on heater. You can add some hysteresis.

   Digital Temperature Controller
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(9, 8, 7, 6, 5, 4);

const int LED_RED=10; //Red LED
const int LED_GREEN=11; //Green LED
const int RELAY=12; //Lock Relay or motor

//Key connections with arduino
const int up_key=3;
const int down_key=2;

int SetPoint=30;
//                  SETUP
void setup(){
  //Pull up for setpoint keys
   // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.setCursor(0,1); //Move coursor to second Line
  lcd.print("Temp. Controller");
  digitalWrite(LED_GREEN,HIGH);  //Green LED Off
  digitalWrite(LED_RED,LOW);     //Red LED On
  digitalWrite(RELAY,LOW);       //Turn off Relay
//                  LOOP
void loop(){
  double Temperature = ((5.0/1024.0) * analogRead(A0)) * 100;  //10mV per degree 0.01V/C. Scalling

  lcd.print("Temperature:");    //Do not display entered keys
//Get user input for setpoints  

//Display Set point on LCD
  lcd.print("Set Point:");
  lcd.print("C   ");

//Check Temperature is in limit
if(Temperature > SetPoint)
   digitalWrite(RELAY,LOW);    //Turn off heater
   digitalWrite(LED_GREEN,HIGH);  //Turn on Green LED
  digitalWrite(RELAY,HIGH);    //Turn on heater
  digitalWrite(LED_RED,HIGH);  //Turn on RED LED  

  delay(100); //Update at every 100mSeconds



This code demonstrates how to construct digital temperature controller using arduino.

We have used combination of LCD and Temperature sensor LM35 to make simple temperature controller using Arduino. Apply temperature to LM35 sensor more than set point  it will turn on the relay (Heater). if it is less it will turn off the relay.

14 thoughts on “Arduino Temperature Controller

  1. HI,
    I am really interested with yours project, I start the project and copy the sketch from yours to my IDE and uploaded into the arduino board. But there is some thing wrong with the set point number and the button, The set point number on LCD goes to raising until the maximum value and the buttons (up_key or down_key) didn’t work.

    what’s wrong with the sketch and how to fix it?

    Thank You for the problem solved.

  2. Hi,
    What is the maximum temperature in Degree Celsius which I can control using Arduino and I would like to control 400+ Deg Celsius is that is possible with this please advise me?

    1. In this temperature controller demo, LM35 temperature sensor is used which is having temperature sensing range of -40C to 150C.
      To measure/control higher temperature change sensor and its calibration according to your requirements.

  3. Hi!
    If we use a LCD shield with the tipical buttons… is possible to use the buttons for change the setpoint? Something like:

    int x;
    x = analogRead (0);
    if (x 0)
    else if (x < 200) {


    1. Here is the hysteresis code

      //Check Temperature is in limit
      if((Temperature -5)> SetPoint)
      digitalWrite(RELAY,LOW); //Turn off heater
      digitalWrite(LED_GREEN,HIGH); //Turn on Green LED
      if((Temperature +5)< SetPoint) { digitalWrite(RELAY,HIGH); //Turn on heater digitalWrite(LED_GREEN,LOW); digitalWrite(LED_RED,HIGH); //Turn on RED LED }

        1. Yes the code works OK for the Hysteresis.
          Note need to add a diode across the relay as when it switches the back emf
          does reset the micro sometimes, also the delay can be slowed a little
          stop the display updating so fast form 250 to m500ms

Leave a Reply