Home Automation Using GSM Module

1

Hey DiY Projects Lab members today i will show easiest Home Automation Using GSM Module and Arduino Nano 

All Circuit diagram and codes for this project is given, if you want PDF please comment below.

In this project you’re going to build an GSM Based Home Automantion System . where we  can control the home appliances

(T.V. , BULB), using the simple GSM based phone, just by sending SMS through the phone. 

In this Home Automantion System Project, no Smart phone is needed just the any old GSM phone you can control  any

home electronic appliances, from anywhere anytime .

This project is successfully completed because of the  support from NextPCB.

NextPCB is one of the most experienced PCB manufacturers in china , Nextpcb has specialized in the PCB and assembly industry for over 15 years.

Guys if you have a PCB project, please visit their website and get very  exciting discounts and coupons.

Only 0$ for 5-10pcs PCB Prototypes:https://www.nextpcb.com/getcoupan 

Register and get $100 from NextPCB: https://www.nextpcb.com/register?100$ free coupan

See more info about PCB Assembly Capabilities: https://www.nextpcb.com/pcb-assembly-services

What is Home Automation Using GSM module?

It’s nothing but automation of various electronic appliances at home without actual need to physically control.

Let me explain this using an example.

Suppose you are at home, very tired lying on sofa, You want your fan to be switched on.

During this time if you have home automation you can just power on fan from your smartphone which everyone carries in their pockets!

With automation, devices at home such as bulbs, television, fan and other devices can be controlled wirelessly from any part of globe via internet connected device.

Here in this post i will show you simple project which shows how can you automate your home using Nano

Materials required for home automation project

  • Arduino Nano with Atmega328p
  • GSM Module
  • Single channel relay board
  • LED for indications and empty PCB
  • AC bulb holder and plug
  • Regular LED bulb
  • Smartphone with activated Sim card

After these supplies are put together start to solder the components to zero PCB board referring below circuit, You can also get customized PCB for this project by checking out description of video

How it work ?

When you send SMS to GSM module by phone , then GSM receives that SMS and sends it to Arduino.

then Arduino compare this command with predefined command.

if it match with predefined command then then Arduino sends data to relay via relay for turning ON and OFF home appliances .

Here in this project we have used one zero watt bulb .

S.no. Message Operation
1 #A.Start* Bulb ON
2 #A.Stop* Bulb OFF
Start/stop

GSM Module

I have Simcom SIM900a GSM module

GSM module (Global System for Mobile Communications) SIM900A Model is built with Dual Band GSM/GPRS based used in many communication devices which are based on GSM technology.

This is a complete GSM/GPRS module. There are various AT Commands like ATD to dial a call , ATA for answer a call, AT+CMGS to send the SMS ,AT+CMGR to read the message etc.

SIM900a PINOUT                                    

I connect the following Pin from above image to:

5 to: GND (Digital GND near Pin 13)

6 to: 5V of Arduino

2 to: GND of Arduino near 5V

3 to: Digital Pin 0 of Arduino (RX)

4 to: Digital Pin 1 of Arduino (TX)

1 to: (No idea)     From Picture option 789 are not connected to anything.

We can use GSM module using these commands for any GSM Projects

AT Commands

1. To change SMS sending mode : AT+CMGF=1

    mySerial.println("AT+CMGF=1");

2. To read SMS in text mode : AT+CNMI=2,2,0,0,0

 mySerial.println("AT+CNMI=2,2,0,0,0");

3. To make a call : ATD+916209403151; //replace X with number you want to call, change +60 to your country code

mySerial.println("ATD+916209403151;");

4. To disconnect / hangup call : ATH

  mySerial.println("ATH");

5. To redial : ATDL

  mySerial.println("ATDL");

6. To receive a phone call : ATA

    mySerial.println(“ATA”);

 

Circuit Diagram for Home automation using GSM Module

Below is the simple circuit diagram for this project, For any queries which were not answered here you can reach out to me in comments!

Home automation using ESP8266
Home automation using ESP8266

Circuit with explanation

You can make this circuit using breadboard and jumper wires if you don’t have any zero pcb board, just follow these connecting steps

GSM Module connection

5v pin of gsm module goes with+5v pin of nano board and positive power output from relay board, Similarly gnd goes with gnd of nano and negative output side of relay

GSM Sim900A 

  • GSM Rx to Arduino Tx
  • 5v to external 5v supply which can deliver up to 1 amp.
  • Ground to ground.
  • GSM Tx to Arduino Rx.

LED indicator connections

As usual gnd of both LED legs will be connect to gnd of nano while for signal D8 and D9 pins

That was all about this circuit once the circuit is complete we will proceed with upload of code for this project

Arduino code for Home Automation project

Connect Nano board to computer, Open Your Arduino IDE just copy and paste this code and hit that upload button

After this process is complete our project is ready for testing

How To use this project

  1. Connect LED Bulb holder with bulb to relay module then connect AC power source, switch to on
  2. Now when GSM module powers on you can start sending messages , the codes in nano determines on and off position of bulb
  3. Start and stop commands were use in code to power on and off device when START and STOP messages are sent
  4. Now many might have confusions on how to setup SIM , well you just need activated sim which will be insert to GSM module slot
  5. Normal text sent from phone triggers this entire project to work
  6. For indication i have add green and yellow color led’s
  7. Yellow bulb glows when system is on but main bulb is switch off and in reverse case green led glows
  8. Now the automation of LED bulb is complete you can apply same principle and automate various other devices at home

CODE

#include <SoftwareSerial.h> // Library for using serial communication
SoftwareSerial SIM900(7, 8); // Pins 7, 8 are used as used as software serial pins

String incomingData;   
String message = "";   
int relay_pin = 1;    // Initialized a pin for relay module

void setup()
{
  Serial.begin(115200); // baudrate 
  SIM900.begin(19200); // baudrate for GSM 

  pinMode(relay_pin, OUTPUT);    
  digitalWrite(relay_pin, HIGH);  
  SIM900.print("AT+CMGF=1\r");  
  delay(100);
  
  
  SIM900.print("AT+CNMI=2,2,0,0,0\r"); 
  delay(100);
}

void loop()
{
  //Function for receiving sms
  receive_message();

  // if received command is to turn on relay
  if(incomingData.indexOf("Start")>=0)
  {
    digitalWrite(relay_pin, LOW);
    message = "Led is turned ON";
    
    send_message(message);
  }
  
  // if received command is to turn off relay
  if(incomingData.indexOf("Stop")>=0)
  {
    digitalWrite(relay_pin, HIGH);
    message = "Led is turned OFF";
   
    send_message(message);
  }        
}

void receive_message()
{
  if (SIM900.available() > 0)
  {
    incomingData = SIM900.readString(); 
    Serial.print(incomingData); 
    delay(10); 
  }
}

void send_message(String message)
{
  SIM900.println("AT+CMGF=1");       delay(100);  
  SIM900.println("AT+CMGS=\"+916209403151\""); // Replace it with your number
  delay(100);
  SIM900.println(message);   
  delay(100);
  SIM900.println((char)26);  
  delay(100);
  SIM900.println();
  delay(1000);  
}

Video tutorial on Home Automation Using GSM Module

Watch video tutorial for this project here

 

Also if you are new here make sure to have a look on our recently published article on Fingerprint based security system for bike

Share.

About Author

1 Comment

  1. Pingback: Infrared Thermometer using Arduino - DiY Projects Lab

Leave A Reply