05 August, 2018

ARDUINO BASED HOME AUTOMATION

ARDUINO BASED HOME AUTOMATION


          The main objective of this project is to develop a home automation system using an Arduino board with LM35 and PIR sensors. As technology is advancing so houses are also getting smarter. Modern houses are gradually shifting from conventional switches to centralized control system, involving remote controlled switches. Presently, conventional wall switches located in different parts of the house makes it difficult for user to go near them to operate. Even more it becomes more difficult for elderly or physically handicapped people to do so.


                In ordered to achieve this, a Temperature sensor (LM35) and Passive Infrared Sensor (PIR) are interfaced with an Arduino board. PIR sensor will sense the human being and controls the bulb switching ON/OFF. LM35 sense the temperature of the room and it used to control the speed of fan automatically. The loads are connected to Arduino board through relays.

Source Code :

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
const int PIR = 12;
const int bulb = 13;
const int tempPin = A1;
const int fan = 11;
char data = 0;
int temp;
int tempMin = 30;
int tempMax = 60;
int fanSpeed;
int fanLCD;
int pirState = 0;

void setup() {
  pinMode(PIR, INPUT);
  pinMode(bulb, OUTPUT);
  pinMode(fan, OUTPUT);
  pinMode(tempPin, INPUT);
  lcd.begin(16, 2);
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() > 0)
  {
    data = Serial.read();
    Serial.print(data);
    Serial.print("\n");
  }
  pirState = digitalRead(PIR);
  if ((pirState == HIGH) && (data == '1'))
  {
    digitalWrite(bulb, HIGH);
    lcd.setCursor(0, 1);
    lcd.print("Bulb ON");
  }
  if ((pirState == LOW) && (data == '0'))
  {
    digitalWrite(bulb, LOW);
    lcd.print("Bulb OFF");
  }
  if
  (temp = readTemp());
  Serial.print( temp );
  if (temp < tempMin)
  {
    fanSpeed = 0;
    analogWrite(fan, fanSpeed);
    fanLCD = 0;
    digitalWrite(fan, LOW);
  }
  if ((temp >= tempMin) && (temp <= tempMax))
  {
    fanSpeed = temp;
    fanSpeed = 1.5 * fanSpeed;
    fanLCD = map(temp, tempMin, tempMax, 0, 100);
    analogWrite(fan, fanSpeed);
    lcd.setCursor(0, 0);
    lcd.print("TEMP: ");
    lcd.print(temp);
    lcd.print("C ");
    delay(200);
    lcd.clear();
    }
}

int readTemp() {
  temp = analogRead(tempPin);
  return temp * 0.48828125;
}

Labels: , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home