@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:fade-in 50ms ease-in-out 2s forwards}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation:none;transition:opacity 50ms ease-in-out}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation:none}[data-language] code.rainbow-show,[class^="lang"] code.rainbow-show,pre [data-language].rainbow-show,pre [class^="lang"].rainbow-show{opacity:1}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}code span{transition:color 0.6s ease-in}code .red{color:#f50419}code .orange{color:#f57900}code .yellow{color:#f5e600}code .green{color:#00f50c}code .blue{color:#0081f5}code .indigo{color:#5000f5}code .violet{color:#9000f5}code .animate{color:#fff !important}pre{background:#010104}pre .comment{color:#747474}pre .keyword,pre .selector,pre .operator{color:#bc5cff}pre .storage,pre .support{color:#fb2639}pre .string{color:#fff55c}pre .constant{color:#ffad5c}pre .entity{color:#43a6ff}pre .inherited-class,pre .storage{font-style:italic}[data-language="custom"] .comment,.lang-custom .comment,.language-custom .comment{color:#314CAD}[data-language="custom"] .integer,.lang-custom .integer,.language-custom .integer{color:#f5e600}[data-language="custom"] .keyword,.lang-custom .keyword,.language-custom .keyword{color:#f57900}[data-language="html"] .attribute,.lang-html .attribute,.language-html .attribute{color:#fc4959} Easy Mades: Smart Home with SIM 800L Module

Smart Home with SIM 800L Module





When the technology is developed the smart home concept came to the picture as a way of simplifying the day today activities. Even though the technology is interested, the investment on such high tech equipment are difficult to most of us.

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 Smart Home concept, but this would be more fun and useful us to improve our knowledge as well as in the practice.

This project is mainly build 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.





POWER SUPPLY

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.
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


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; int Switch_2 = 5; int Switch_3 = 6; int Switch_4 = 7; int Switch_5 = 8; 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 

                

0 comments:

-->
Copyright © 2013 Easy Mades
var rainbow = require('rainbow-code'); var highlighted = rainbow.colorSync('var foo = true;', 'javascript');