Forum Replies Created
Viewing 1 post (of 1 total)
-
AuthorPosts
-
AryanParticipant
Well after a long time troubleshooting i found that problem was that i was not using delay function after AT commands.
Working code enjoy
#include<String.h>int temp4=0;int lenth,lenth1,i=0,temp=0;String str="";String nam="";String number="";String m="Status";void setup() {pinMode (9,OUTPUT);Serial3.begin(9600);Serial.begin(9600);Serial3.println("AT+CNMI=2,2,0,0,0");Serial3.println("AT+CMGF=1");delay(100);if (Serial3.available()>0)Serial.write(Serial3.read());}void loop(){while(temp!=0){i=0;while(i<lenth){if(str=='"'){temp4++;}if(temp4==1){for(int j=0;j<15;j++){number+=str;i++;}temp4=2;}if(str=='*'){i++;while(str!='#'){nam+=str;i++;}}i++;}Serial.print(nam);if (nam.compareTo(m)==0){SendMessage();}delay(2000);temp=0;temp4=0;nam="";lenth=0;str="";number="";delay(1000);}}void serialEvent3(){while (Serial3.available()){char inChar = (char)Serial3.read();str+=inChar;lenth++;if (inChar == 'n'){ temp=1;inChar=0;}}}void SendMessage(){digitalWrite(9,HIGH);Serial3.println("AT+CMGF=1"); //Sets the GSM Module in Text Modedelay(1000); // Delay of 1000 milli seconds or 1 secondSerial3.println("AT+CMGS="+918557803648"r"); // Replace x with mobile numberdelay(1000);Serial3.println("I am SMS from GSM Module");// The SMS text you want to senddelay(100);Serial3.println((char)26);// ASCII code of CTRL+Zdelay(100);} -
AuthorPosts
Viewing 1 post (of 1 total)