Microcontroller › Arduino › Home automation
- This topic has 1 reply, 2 voices, and was last updated 9 years ago by Vara Ashishkumar.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
December 7, 2015 at 2:40 pm #4150HimanshuParticipant
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 13int 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 senddelay(100);mySerial.println((char)26);// ASCII code of CTRL+Zdelay(1000); // give module time to send SMSSerial.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 senddelay(100);mySerial.println((char)26);// ASCII code of CTRL+Zdelay(1000);Serial.println("SMS sent successfully");}}December 9, 2015 at 12:15 pm #13566Vara AshishkumarParticipantHey Himanshu,
Please discribe your application in brief so i will solve your stuff.
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.