--> Project III - 7. Thermostat with LCD and 3 Additional Button (Arduino Based) | basic arduino tutorial

Wednesday, August 9, 2017

Project III - 7. Thermostat with LCD and 3 Additional Button (Arduino Based)

| Wednesday, August 9, 2017
Thermostat with LCD and 3 Additional Button




Thermostat is a tool used to keep the level of the temperature in accordance with the set point that has been determined. The temperature is read analog data by the LM35 sensor and the result will shown on the LCD. To set the Set point can use some button. So that will make it easier to change the set point value without re-upload the different program. The heater is controlled by using a relay that connected to the output of the Arduino Uno Pin.


Hardware Requirement
  • Relay Module 5V with Single Channel
  • Arduino UNO
  • Element Heater
  • 3 Push Button
  • LM35 Temperature Sensor
  • Power supply +5 Volt
  • Jumper
                        LM35 Temperature Sensor | Source                 Relay with Single Channel | Source


Elemetn Heater | Source

Block Diagram




Schematic



Arduino - LCD Wiring



Arduino - LM35 Wiring


Arduino - Relay Wiring


Arduino - Buttton Wiring



Source Code/Sketch


#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
byte derajat[8] = {
0b01100,
0b10010,
0b10010,
0b01100,
0b00000,
0b00000,
0b00000,
0b00000
};
int adc,T,setPoint;
byte setSP, f_awal;
long lastButton = 0;
long delayAntiBouncing = 50;
void setup(){
pinMode(8,OUTPUT);
pinMode(9,INPUT);
pinMode(10,INPUT);
pinMode(11,INPUT);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
lcd.createChar(1, derajat);
lcd.begin(16, 2);
lcd.print(" Thermostat ");
lcd.setCursor(0, 1);
lcd.print("ARDUINO dg LM35");
delay(2000);
lcd.clear();
setPoint=40;
}
void loop(){
lcd.setCursor(0,0);
lcd.print("SP=");
lcd.print(setPoint);
lcd.write(1);
lcd.print("C ");
adc = analogRead(0);
T=(adc*5)/10;
lcd.setCursor(8, 0);
lcd.print("T=");
lcd.print(T);
lcd.write(1);
lcd.print("C ");
if(T<(setPoint-1) || f_awal==0){
lcd.setCursor(0,1);
lcd.print("Heater ON ");
digitalWrite(8,HIGH);
f_awal=1;
}
else if(T>=setPoint){
lcd.setCursor(0,1);
lcd.print("Heater OFF");
digitalWrite(8,LOW);
}
tombol();
delay(100);
}
void tombol(){
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
if(digitalRead(9)==0){
lcd.clear();
lcd.print("Seting Set Point");
lcd.setCursor(9,0);
delay(1000);
lcd.clear();
setSP++;
//-----------------program looping seting set point
do{
if(digitalRead(9)==0){
if ((millis() - lastButton) > delayAntiBouncing){
setSP++;
}
lastButton = millis();
}
else if(digitalRead(10)==0){
if ((millis() - lastButton) > delayAntiBouncing){
setPoint++;
}
lastButton = millis();
}
else if(digitalRead(11)==0){
if ((millis() - lastButton) > delayAntiBouncing){
if (setPoint>0){
setPoint--;
}
}
lastButton = millis();
}
lcd.setCursor(0,0);
lcd.print("SP=");
lcd.print(setPoint);
lcd.write(1);
lcd.print("C");
}
while (setSP<2);
setSP=0;
f_awal=0;
lcd.clear();
lcd.print("Set point OK!");
delay(1000);
lcd.clear();
}
}

How it Works


1. Connect the Arduino with Peripherals needed
2. Plug in the Power Source on the device
3. Compile and upload the script program above to your arduino
4. Initial Display on LCD


5. After 2 second, display will change and show the temperature data like an image below



     * SP --> Set Point. T --> Temperature. Heater Off --> Status of Heater

6. If the temperature is 40 or more, so the heater will turn off, and if the temperature is 20 or less
    than it, the heater will turn on again.

7. To set the set point value, you can use set button and up/down button to change the digit number


8. If you're done setting it up, then press set button once again to save the current set point


9. Finally :)


Tips -- > 
           To get a stable temperature you can create a separate supply voltage on the LM35 sensor with a supply voltage from 5Vdc to 15Vdc.  The greater the power used, the more accurate the measurement results. As long as not exceed 15 V.


Video for Project III - 7. Thermostat with LCD and 3 Additional Button (Arduino Based)




Required file 


Related Posts

No comments:

Post a Comment