--> Project III - 8. Thermostat and 3x4 Keypad Module (Arduino Based) | basic arduino tutorial

Wednesday, August 9, 2017

Project III - 8. Thermostat and 3x4 Keypad Module (Arduino Based)

| Wednesday, August 9, 2017
Thermostat and 3x4 Keypad Module




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. You can use 3x4 Keypad module to set the Set point . 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
  • 3x4 Keypad Module
  • LM35 Temperature Sensor
  • Power supply +5 Volt
  • Jumper

                      LM35 Temperature Sensot | Source      Relay with 1 Channel | Source





                             3x4 Keypad module | Source                Element Heater | Source



Block Diagram



Schematic




Arduino - LCD Wiring



Arduino - 3x4 Keypad Wiring


Arduino - LM35 Wiring


Arduino - Relay Wiring



Source Code/Sketch


#include <LiquidCrystal.h>
#include <Keypad.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
byte derajat[8] = {
0b01100,
0b10010,
0b10010,
0b01100,
0b00000,
0b00000,
0b00000,
0b00000
};
char key;
byte SPkeypad;
byte T,setPoint;
byte setSP, f_awal;
const byte ROWS=4;
const byte COLS=3;
char keys[ROWS][COLS]={
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS]={9,10,11,12};
byte colPins[COLS]={A1,A2,A3};
Keypad keypad = Keypad(makeKeymap(keys),rowPins, colPins, ROWS, COLS);
void setup(){
pinMode(8,OUTPUT);
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 ");
T=(analogRead(0)*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("Set=* Heater ON ");
digitalWrite(8,HIGH);
f_awal=1;
}
else if(T>=setPoint){
lcd.setCursor(0,1);
lcd.print("Set=* Heater OFF");
digitalWrite(8,LOW);
}
delay(100);
bacaKeypad();
}
void bacaKeypad(){
key=keypad.getKey();
if(key != NO_KEY){
if (key=='*'){
lcd.clear();
lcd.print("Seting Set Point");
delay(1000);
lcd.clear();
lcd.print("SP= ");
lcd.write(1);
lcd.print("C ");
lcd.blink();
lcd.setCursor(3,0);
byte kursor=3;
byte selesai=1;
do{
key=keypad.getKey();
if(key != NO_KEY){
if (key!='*' && key!='#' && kursor<5){
lcd.print(key);
key=key-48;
SPkeypad=SPkeypad*10;
SPkeypad=SPkeypad+key;
kursor++;
lcd.setCursor(kursor,0);
}
else if (key=='#' && kursor==5){
selesai=0;
}
}
if(kursor==5){
lcd.noBlink();
lcd.setCursor(0,1);
lcd.print("Save tekan #");
}
}
while(selesai);
setPoint = SPkeypad;
SPkeypad = 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. The heater will turn off  if the temperature is equivalen or more than Set Point value
6. The heater will turn on again if the temperature is 20 or less than 20 degrees


7. To set the set point value, just press "*" button and you can use set keypad number to fill in the digit number form


8. Set the set as needed


9. If you're done setting it up, then press "#" button to save the current set point




10. Done




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 - 8. Thermostat and 3x4 Keypad Module (Arduino Based)




Required File 


Related Posts

No comments:

Post a Comment