Home Automation: Sound Alarm and LCD display when temp is above threshold using Arduino

This blog will demonstrate how to make a Home Automation System which will start sounding a alarm whenever temperature reaches more than the programmed threshold value. It will keep displaying the current temp of the room on the LCD and action needed (Ex: Decrease Temp) when temp reaches more than threshold value. In this tutorial, I am using AD22100 temp sensor which is manufactured by Analog Devices and AG-1005G Buzzer. AD22100 is a Voltage Output Temperature Sensor with Signal Conditioning.

Before going further, I am assuming that you have already gone through the Arduino Basics and are familiar with programming Arduino boards using Arduino IDE.

If not, go through my previous blogs Arduino Basics and LED Blinking on Arduino.

For connecting LCD to Arduino Board, please go through this blog LCD Display

For connecting AD22100, Click here AD22100 Arduino. For connect Buzzer, Click here

Program on Arduino Software

You can copy and paste whole program from here.

Compile it and Upload it on Arduino Board and observe Home Automation System demo

//Program starts here

int val;
int tempPin = A1;
int buzzer = 6;
#include

LiquidCrystal lcd (7,8,9,10,11,12);

void setup() {
// put your setup code here, to run once:
lcd.begin(16,2);
lcd.clear();
Serial.begin(9600);
pinMode(buzzer, OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
val = analogRead(tempPin);//AD22100 is connected at Pin A1
/*
*For 25C, val comes as 900 that means
* 900 is corresponding to 1.9375 v
* Transfer Function is (V+/5)*(1.375 + 22.5 mv/degC * 25 degC),
* Read Datasheet of AD22100
*/
float cel = ((((1.9375/900) * val) – 1.375)/22.5)*1000;
float farh = (cel*9)/5 + 32;

Serial.print(val);
Serial.println();
Serial.print(“TEMPRATURE = “);
Serial.print(cel);
Serial.print(“*C”);
Serial.println();
if (cel > 26)
{
tone(buzzer, 1000);
lcd.clear();
lcd.print(“Temp above threshold”);
lcd.setCursor(0,1);
lcd.print(“Decrease Temp”);
}
else
{
noTone(buzzer);
lcd.clear();
lcd.print(“Temp under control”);
lcd.setCursor(0,1);
lcd.print(“Temp= “);
lcd.print(cel);
lcd.print(“degC”);
}
delay(500);
}

//Program ends here

Explanation of program:

Functions related to LCD library, Buzzer have already explained in previous blog.

For converting the AnalogRead value from Temp sensor, I am using a transfer function. For understanding that go through previous blog related to AD22100 and LCD.

In this blog, i am using condition checking statement which is if and else block.

If temp is greater than threshold value, I am sending a signal to the buzzer to sound an alarm and displaying on LCD to decrease the temp with below section of the code

if (cel > 26)
{
tone(buzzer, 1000);
lcd.clear();
lcd.print(“Temp above threshold”);
lcd.setCursor(0,1);
lcd.print(“Decrease Temp”);
}

If not then sending the current value of temp to LCD and displaying that temp is in control.

else
{
noTone(buzzer);
lcd.clear();
lcd.print(“Temp under control”);
lcd.setCursor(0,1);
lcd.print(“Temp= “);
lcd.print(cel);
lcd.print(“degC”);
}

Once the code is uploaded on Arduino, Try to increase the temp and see the effect on buzzer and LCD when temp reaches more than the threshold value.

Demo of Program

Here is the snapshot of the demo set up of AD22100, Buzzer and LCD connection with Arduino Board.

home-automation

Please look at the whole demonstration on Youtube here Home Automation using Arduino.

-Signing Off, Arduino Novice

Please do follow my Blog and subscribe to my Youtube Channel for more demos and videos related to Arduino.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s