Imagine being able to control your home appliances from anywhere in the world using just your mobile phone. This is possible with a GSM-based home automation system. In this project, we will use an Arduino, a GSM module (SIM900A), and an LCD to control various devices like a fan, light, and TV via SMS commands.
Overview
Components Needed
Arduino UnoGSM Module (SIM900A)
LCD Display (16x2)
Relay Module
Jumper Wires
Power Supply
Fan, Light, TV (or any other devices you want to control)
Block Diagram:
- Mobile Phone: Sends SMS commands.
- GSM Module (SIM900A): Receives SMS commands.
- Arduino: Processes commands and controls devices.
- Devices: Fan, Light, TV.
- LCD: Displays the status of devices.
Circuit Diagram:
Block Diagram of GSM Based Home Automation using Arduino
Circuit Diagram of GSM Based Home Automation using Arduino
Circuit Connections
GSM Module to Arduino:TX of GSM Module → RX of Arduino
RX of GSM Module → TX of Arduino
GND of GSM Module → GND of Arduino
VCC of GSM Module → 5V of Arduino
LCD to Arduino:RS → Pin 6
EN → Pin 7
D4 → Pin 8
D5 → Pin 9
D6 → Pin 10
D7 → Pin 11
Devices to Arduino (through Relay Module):Fan → Pin 3
Light → Pin 4
TV → Pin 5
Working Principle
Sending Commands: Send SMS commands from any mobile phone to the GSM module.Receiving Commands: The GSM module receives the messages and forwards them to the Arduino.
Processing Commands: Arduino extracts instructions from the message and performs the required operation (turning devices on/off).
Displaying Status: The status of each device is displayed on the LCD.
#include <LiquidCrystal.h>
LiquidCrystal lcd(6, 7, 8, 9, 10, 11);
#define Fan 3
#define Light 4
#define TV 5
int temp = 0, i = 0;
int led = 13;
char str[15];
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(Fan, OUTPUT);
pinMode(Light, OUTPUT);
pinMode(TV, OUTPUT);
lcd.setCursor(0, 0);
lcd.print("GSM Control Home");
lcd.setCursor(0, 1);
lcd.print(" Automation ");
delay(2000);
lcd.clear();
lcd.print("Initializing");
delay(1000);
lcd.setCursor(0, 1);
lcd.print("System Ready");
Serial.println("AT+CNMI=2,2,0,0,0");
delay(500);
Serial.println("AT+CMGF=1");
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Fan Light TV");
lcd.setCursor(0, 1);
lcd.print("OFF OFF OFF ");
}
void loop() {
lcd.setCursor(0, 0);
lcd.print("Fan Light TV");
if (temp == 1) {
check();
temp = 0;
i = 0;
delay(1000);
}
}
void serialEvent() {
while (Serial.available()) {
if (Serial.find("#A.")) {
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
while (Serial.available()) {
char inChar = Serial.read();
str[i++] = inChar;
if (inChar == '*') {
temp = 1;
return;
}
}
}
}
}
void check() {
if (!(strncmp(str, "tv on", 5))) {
digitalWrite(TV, HIGH);
lcd.setCursor(13, 1);
lcd.print("ON ");
delay(200);
} else if (!(strncmp(str, "tv off", 6))) {
digitalWrite(TV, LOW);
lcd.setCursor(13, 1);
lcd.print("OFF ");
delay(200);
} else if (!(strncmp(str, "fan on", 5))) {
digitalWrite(Fan, HIGH);
lcd.setCursor(0, 1);
lcd.print("ON ");
delay(200);
} else if (!(strncmp(str, "fan off", 7))) {
digitalWrite(Fan, LOW);
lcd.setCursor(0, 1);
lcd.print("OFF ");
delay(200);
} else if (!(strncmp(str, "light on", 8))) {
digitalWrite(Light, HIGH);
lcd.setCursor(7, 1);
lcd.print("ON ");
delay(200);
} else if (!(strncmp(str, "light off", 9))) {
digitalWrite(Light, LOW);
lcd.setCursor(7, 1);
lcd.print("OFF ");
delay(200);
} else if (!(strncmp(str, "all on", 6))) {
digitalWrite(Light, HIGH);
digitalWrite(Fan, HIGH);
digitalWrite(TV, HIGH);
lcd.setCursor(0, 1);
lcd.print("ON ON ON ");
delay(200);
} else if (!(strncmp(str, "all off", 7))) {
digitalWrite(Light, LOW);
digitalWrite(Fan, LOW);
digitalWrite(TV, LOW);
lcd.setCursor(0, 1);
lcd.print("OFF OFF OFF ");
delay(200);
}
}
downloade clock here
Commands
#A.fan on*
- Turn on the fan#A.fan off*
- Turn off the fan#A.light on*
- Turn on the light#A.light off*
- Turn off the light#A.tv on*
- Turn on the TV#A.tv off*
- Turn off the TV#A.all on*
- Turn on all devices#A.all off*
- Turn off all devices
Conclusion
This GSM-based home automation project allows you to control your home appliances from a distance using SMS commands. It’s a simple yet powerful way to add automation to your home, making your life easier and more convenient. Happy building!
nice post
ReplyDelete