EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Home automation

Home automation

|

Microcontroller › Arduino › Home automation

  • This topic has 1 reply, 2 voices, and was last updated 10 years, 2 months ago by Vara Ashishkumar.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • December 7, 2015 at 2:40 pm #4150
    Himanshu
    Participant

    Hey hi,

    I am having problem in recieving and reading messages. There is a variable time lag betweenn message delivery and recieving. I am using simcom sim900A module. All I want is to make this program work. So that it receives message and reads it and acts correspondingly.

    Please help me out its urgent.

     

    #include <SoftwareSerial.h>
     
    SoftwareSerial mySerial(11, 12);
     
     
    #define TV 13
     
     
     
    int lenth,lenth1,i=0,temp=0;
     
    String str="";
    String name="";
     
    int flag=0;
    String ON="ON";
    String OFF="OFF";
     
     
     
    void setup()
    {
       mySerial.begin(9600);
       Serial.begin(9600);
       delay(100); 
     
         pinMode(TV, OUTPUT);
         digitalWrite(TV, HIGH);
     
      delay(1000);
      Serial.println("setup complete");
    }
     
    void loop()
    {
      if(flag==0)
    { Serial.println("loop"); 
      delay(1000);
      mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to recieve a live SMS
       
    } 
      if(mySerial.available()>0) 
      { flag=1;    
        char inChar = (char)mySerial.read(); 
        str+=inChar;
         lenth++;
        if (inChar == 'n')
        {      temp=1;  
          inChar=0; }   
    }
       while(temp!=0)
       {
        i=0;
        
        while(i<lenth)          
        {
         
         if(str=='*')
         {
          i++; 
          while(str!='#')
          {
           name+=str;
           i++;
          }
         }
         i++;
        }
     
     
        check();
     
        delay(200);
     
        temp=0;
     
        name="";
        lenth=0;
        str="";
        flag=0;
        
         mySerial.print("AT+CMGDA="DEL ALL"r");
        delay(100);
       }
       
     
    }
     
     
    void check()
    {
       if(name == ON)
        { Serial.println("got something to on");
          digitalWrite(TV, HIGH);
          delay(1000);
          mySerial.println("AT+CMGF=1");
          delay(1000);
          mySerial.println("AT+CMGS="+918*******4"r");
          delay(1000);
          mySerial.println("TV ON");                         // message to send
          delay(100);
          mySerial.println((char)26);// ASCII code of CTRL+Z
          delay(1000);     // give module time to send SMS
          Serial.println("SMS sent successfully");
              
        }
     
        if (name == OFF)
        { Serial.println("got something to off");
          digitalWrite(TV,LOW);
          delay(1000);
           mySerial.println("AT+CMGF=1");
          delay(1000);
          mySerial.println("AT+CMGS="+918********4"r");
          delay(1000);
          mySerial.println("TV OFF");                         // message to send
          delay(100);
          mySerial.println((char)26);// ASCII code of CTRL+Z
          delay(1000);
          Serial.println("SMS sent successfully");
     
        }
     
      
    }
    December 9, 2015 at 12:15 pm #13566
    Vara Ashishkumar
    Participant

    Hey Himanshu,

    Please discribe your application in brief so i will solve your stuff.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Harman Kardon radio module BMW noise February 16, 2026
  • Arduino standalone minimal February 16, 2026
  • analog logic of shmidt trigger bjt circuit February 16, 2026
  • CR2/CR123A Batteries In Projects February 16, 2026
  • Math problem February 15, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise