Tuesday 7 January 2020

Smart Home Project Idea with SIM 800L Module









When the technology is developed the smart home concept came to the picture as a way of simplifying the day to day activities. Even though the technology is interesting, the investment in such high-tech equipment is difficult for most of us. It is one side highly cost and you may need more technology and to do more research works.





Therefore, it is more suitable to use low-cost DIY projects to fulfill the requirement. I am not going to cover all the areas of the Smart Home concept, but this would be more fun and use us to improve our knowledge as well as in the practice.





This project is mainly built on the SIM 800 L GPRS/GSM module. This module can be used with a SIM card. All the code related to SIM 800L module can be downloaded from the link below.







You must insert the sim card to the correct Direction as shown in the sim card slot.





The SIM 800L module is controlled by the Arduino programme. I have used ATMEGA 328p chip to control the module.














The Circuit Diagram as follow.










If you need more details about wiring, you can watch the following video.

















THE BEST POWER SUPPLY FOR SIM 800




For testing purposes, you can give the power to the module from the 5 volt pin of the arduino. But if you give separate power you have to regulate the voltage t 4.7 volt and it will be more efficient if you use the following module with 2A current.





















OUTPUTS IN Different WAYS.


I have used 5 output and LEDs are connected to testing purposes. But if you want to connect any other equipment, you can use the following circuit instead of the LEDs.







Connection through a RELAY



If you connect a relay like this instead of LEDs, you can control most of devices even 230v requirements as well. Read the circuit well and understand the wiring.












Connection through an optocoupler













Connection through a MOSFET











The  CODE is as follow.




You can change the codes to following modifications




1.       Store the ON/OFF situation in to the memory : Even the power is disconnected, the settings will be restored to the last situation




2.       Allow to send codes from any phone and reply to a specific phone or to the same phone




3.       Allow to send codes from specific phone and reply to a specific phone or to the same phone







#include <SoftwareSerial.h>
#include <Sim800l_EM.h>
Sim800l Sim800l;
unsigned long bauds = 9600;

String SMScontain; // SMS contain only
String SMSsender; // SMS sender's Name
String text; // Detail SMS
String ReadTXT ="Test" ;
int NUMSMS; //SMS storage
long MSGlen;
uint8_t SMS_QTY;
String dt;
uint8_t index=1;
bool error;
String ReadMsg;
int Switch_1 = 4;// Out Put Pins
int Switch_2 = 5;// Out Put Pins
int Switch_3 = 6;// Out Put Pins
int Switch_4 = 7;// Out Put Pins
int Switch_5 = 8;// Out Put Pins


void setup(){
Serial.begin(bauds);
pinMode(Switch_1,OUTPUT);
pinMode(Switch_2,OUTPUT);
pinMode(Switch_3,OUTPUT);
pinMode(Switch_4,OUTPUT);
pinMode(Switch_5,OUTPUT);


Sim800l.begin();
delay(5000);
Serial.print("Ready to Work");
}


void loop(){
//-------------------------------------------------------------
// Get SMS storage amount -------------------------------------
//-------------------------------------------------------------
Sim800l.AT();
delay(500);
//Serial.read();

int NUMSMS = Sim800l.getCountsms();
//SMScontain = Sim800l.readMSG(8);
//delay(500);
Serial.println(NUMSMS);
if (NUMSMS !=0 ){

//-------------------------------------------------------------

SMScontain = Sim800l.readMSG(index); // Filter SMS contain
SMScontain.trim();
text = SMScontain;
delay(1000);
ReadTXT = text;

//-----------------------------------------------
//===============================================
if (text.length() > 0){ // GET SENDER NUMBER
//===============================================

SMSsender = Sim800l.getNumberSms(index);
SMSsender =SMSsender.substring(0,12);
SMSsender.trim();
//Serial.println(SMSsender.length() );
//Serial.println(text);
Sim800l.delAllSms();
// SMSsender = "+12345678910" // If you want to get fead back to a perticular number
//-----------------------------------------------
// FILTER MSG CONTAIN----------------------------
//-----------------------------------------------

if (SMScontain.length() > 0){
Serial.print("SMSsender: ");
Serial.println(SMSsender);
Serial.print("SMS : ");
Serial.println(SMScontain);
}
//----------------------------------------------

} //===============================================

} // END ------------------------------------>


//*************************************************
//ON OFF by SMS Switch 1----------------------------------
//*************************************************

if (SMScontain == "ON 1"){
digitalWrite(Switch_1,HIGH);
error=Sim800l.sendSms(SMSsender,"Switch 01 ON"); // Active if you want a feadback
delay(500);}
else if (SMScontain == "OFF 1"){
digitalWrite(Switch_1,LOW);
error=Sim800l.sendSms(SMSsender,"Switch 01 OFF"); // Active if you want a feadback
delay(500);}
//*************************************************
//*************************************************
//ON OFF by SMS Switch 2----------------------------------
//*************************************************

if (SMScontain == "ON 2"){
digitalWrite(Switch_2,HIGH);
error=Sim800l.sendSms(SMSsender,"Switch 02 ON"); // Active if you want a feadback
delay(500);}
else if (SMScontain == "OFF 2"){
digitalWrite(Switch_2,LOW);
error=Sim800l.sendSms(SMSsender,"Switch 02 OFF"); // Active if you want a feadback
delay(500);}
//*************************************************

//*************************************************
//ON OFF by SMS Switch 3----------------------------------
//*************************************************

if (SMScontain == "ON 3"){
digitalWrite(Switch_3,HIGH);
error=Sim800l.sendSms(SMSsender,"Switch 03 ON"); // Active if you want a feadback
delay(500);}
else if (SMScontain == "OFF 3"){
digitalWrite(Switch_3,LOW);
error=Sim800l.sendSms(SMSsender,"Switch 03 OFF"); // Active if you want a feadback
delay(500);}
//*************************************************

//*************************************************
//ON OFF by SMS Switch 4----------------------------------
//*************************************************

if (SMScontain == "ON 4"){
digitalWrite(Switch_4,HIGH);
error=Sim800l.sendSms(SMSsender,"Switch 04 ON"); // Active if you want a feadback
delay(500);}
else if (SMScontain == "OFF 4"){
digitalWrite(Switch_4,LOW);
error=Sim800l.sendSms(SMSsender,"Switch 04 OFF"); // Active if you want a feadback
delay(500);}
//*************************************************


//*************************************************
//ON OFF by SMS Switch 5----------------------------------
//*************************************************

if (SMScontain == "ON 5"){
digitalWrite(Switch_5,HIGH);//error=Sim800l.sendSms(SMSsender,"Switch 05 ON"); // Active if you want a feadback
delay(500);}
else if (SMScontain == "OFF 5"){
digitalWrite(Switch_5,LOW);
error=Sim800l.sendSms(SMSsender,"Switch 05 OFF"); // Active if you want a feadback
delay(500);}
//*************************************************

//*************************************************
//ON OFF by SMS all----------------------------------
//*************************************************

if (SMScontain == "ON ALL"){
digitalWrite(Switch_1,HIGH);
digitalWrite(Switch_2,HIGH);
digitalWrite(Switch_3,HIGH);
digitalWrite(Switch_4,HIGH);
digitalWrite(Switch_5,HIGH);
error=Sim800l.sendSms(SMSsender,"ALL Switch ON"); // Active if you want a feadback
delay(500);}
else if (SMScontain == "OFF ALL"){
digitalWrite(Switch_1,LOW);
digitalWrite(Switch_2,LOW);
digitalWrite(Switch_3,LOW);
digitalWrite(Switch_4,LOW);
digitalWrite(Switch_5,LOW);
error=Sim800l.sendSms(SMSsender,"ALL Switch OFF"); // Active if you want a feadback
delay(500);}
//*************************************************

//Clear Data
SMSsender ="";
SMScontain="";
text="";
if (NUMSMS >1){
Sim800l.delAllSms();}

} //END Void Loop




Click on following to download Library 


                
Previous Post
Next Post

post written by:

1 comment:

  1. Thanks for sharing such an Awesome Project. Can you please add one more feature to this Home Automation System by using one Arduino pin connected to an PIR Sensor with a command to activate & deactivate the Intrusion Alert sending to a remotely programmed number in sim800l module. I think this will provide security in addition to home automation as user can trigger Hooter & Lights on in case he gets any intrusion alerts on his phone.

    ReplyDelete