Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based Smart Water Heater Controller with Keypad and Temperature Sensor

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Water Heater Controller with Keypad and Temperature Sensor

Circuit Documentation

Summary

This circuit is designed to control a water heater using an Arduino UNO microcontroller. It includes a 4x4 membrane matrix keypad for user input, a DS18B20 temperature sensor for monitoring the water temperature, and an SSR-25A solid-state relay to control the water heater. The system is powered by a 220V power source.

Component List

Arduino UNO

4X4 Membrane Matrix Keypad

SSR-25A

DS18B20 1-Wire Temperature Sensor Probe Cable

Water Heater

Resistor (200 Ohms)

Power 220V

Wiring Details

Arduino UNO

4X4 Membrane Matrix Keypad

SSR-25A

DS18B20 1-Wire Temperature Sensor Probe Cable

Water Heater

Resistor (200 Ohms)

Power 220V

Documented Code

#include <Keypad.h>
#include <Wire.h>
#include <EEPROM.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2 
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
LiquidCrystal_I2C lcd(0x27, 16, 2);

char customKey, mulaiKey;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
 {'1', '2', '3', 'A'},
 {'4', '5', '6', 'B'},
 {'7', '8', '9', 'C'}, 
 {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {11,10,9,8};
byte colPins[COLS] = {7,6,5,4};

int x = 0;
int ssr = 3; // alamati pin SSR
float sp;
float diff, temp_now;
float T_cutoff, T_cuton, nilaicd, nilaisp, nilaidiff; 
Keypad customKeypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void(* resetFunc) (void) = 0; //declare reset function @ address 0

void setup()
{
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  pinMode(ssr, OUTPUT);
  sp = 0;
  diff = 0;
  nilaisp = sp;
  nilaidiff = diff;
  T_cutoff = sp + (diff / 2);
  T_cuton = sp - (diff / 2);
  delay(50);
  lcd.clear();

  // Tampilkan pesan "Selamat Datang"
  lcd.setCursor(0, 0);
  lcd.print("SELAMAT DATANG");
  lcd.setCursor(0, 1);
  lcd.print("TUAN ELFANDY");
  delay(3000); // Tampilkan selama 3 detik
  lcd.clear();
}

void loop()
{
 customKey = customKeypad.getKey();
if(x == 0){
 //lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("1.SET ON-OFF");
}
if(x == 1){
 //lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("2.TES");
}
if(x == 2){
 //lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("3.CEK ON-OFF");
} switch(customKey)
 {
 case '0' ... '9':
 break;
 
 case '#':
 break;
 case '*':
 break;
 case 'A':
 x++; 
 break;
 
 case 'B':
 x--;
 break;
 
 case 'C':
 break;
 
 case 'D':
 if(x == 0){
 lcd.clear();
 //analogWrite(ssr,0);
 setsp();
 setdiff();
 }
 if(x == 1){
 lcd.clear();
 mulai();
 }
 if(x == 2){
 lcd.clear(); 
 //analogWrite(ssr,0);
 cekonoff();
 } 
 break;
 }
if(x > 2){
x = 0;
}
if(x < 0){
x = 2;
}
}

void setdiff(){
 lcd.setCursor(0,0);
 lcd.print("SET DIFF ");
 customKey = customKeypad.getKey();
 if(customKey >= '0' && customKey <= '9')
 {
 diff = diff * 10 + (customKey - '0');
 lcd.setCursor(0,1);
 lcd.print(diff);
 T_cutoff = sp + (diff/2);
 T_cuton = sp - (diff/2);
 }
 
 if(customKey == '*'){ 
 lcd.clear();
 delay(1000);
 nilaid