Introduction: Home Automation: Sound an Alarm and Display on LCD When Temperature Is Above Threshold Value

About: I am a novice to Arduino and have started working on it. I hope to do something good with the Arduino Boards.

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.

Step 1: Parts

You need these parts with you before starting this indestructable to work

1. Arduino UNO Board

2. LCD Display (16x2)

3. Buzzer - 2 Pin (AC-1005G)

4. Temp Sensor - 3 Pin (AD22100)

Step 2: Connection of the Different Parts With Arduino UNO

LCD Connection with Arduino UNO board

LCD RS Pin (Pin 4) with Pin 7 of Arduino Board

LCD Enable Pin (Pin 6) with Pin 8 of Arduino Board

LCD D4 Pin (Pin 11) with Pin 9 of Arduino Board

LCD D5 Pin (Pin 12) with Pin 10 of Arduino Board

LCD D6 Pin (Pin 13) with Pin 11 of Arduino Board

LCD D7 Pin (Pin 14) with Pin 12 of Arduino Board

Add a 10 KΩ Pot to +5v (Pot Pin 1) and GND (Pot Pin 3),

Connect Middle Pin of Pot (Pot Pin 2) to the LCD V0 Pin (Pin 3).

LCD VDD Pin (Pin 2) and LCD A Pin (Pin 15) with +5v on Arduino Board.

LCD VSS Pin (Pin 1) and LCD K Pin (Pin 16) with GND on Arduino Board.

AD22100 Temp Sensor connection with Arduino UNO Board


Pin 1 (V+) of AD22100 should be connected to +5 v on Arduino Board.

Pin 2 (Vo) of AD22100 should be connected to Pin A1 on Arduino Board.

Pin 3 (GND) of AD22100 should be connected to GND on Arduino Board

Buzzer (AC-1005G) Connection with Arduino UNO Board


Pin 6 PWM output of Arduino board should be connected to +ve input of Buzzer.

GND of Arduino Board should be connected with -ve input of Buzzer

Step 3: Arduino Codes

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

Step 4: Understanding Program in Detail

I will try to explain few section of the code.

Functions related to If/else statement

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”);

}

Functions related to Buzzer

tone(buzzer, 1000) — this function will send a 1 khz signal to pin named buzzer which is defined as Pin 6 and Magnetic buzzer is connected at Pin 6.
noTone(buzzer) — will stop sending 1 khz signal. Hence, the ringing will stop

Functions related to Temp Sensor

Conversion of Analog value of temp reading to the deg C value is done using a transfer function which can be find out in the AD22100 Datasheet as written below.

Vout = (V+/5 V) × (1.375 V + 22.5 mV/°C × TA) and the same value is printed on the LCD display.

Step 5: Demo of the Instructables

Once the program is compiled and uploaded on the Arduino UNO board

let us try to increase the temp sensed by temp sensor AD22100 and enjoy the Home Automation system.

For increasing the temp of sensor, I am touching it with soldering iron available in Lab.

You can have a look at the demo here ..

Demo of Home Automation System

Arduino Contest 2016

Participated in the
Arduino Contest 2016