Hi everyone i am facing some problems in my project.
My goal is to turn on the LED in pin 13, By sending a text "on" to my arduino,
but when i read the message in PDU format. the recieved PDU message is truncated or incomplete. I have tried adding more delays, but it doesnt solve the problem. Please help me..
int indicatorPin=13; //Indicator LED pin 13 for test with led.
String readString;
char c;
void delsms(){
Serial.println("AT+CMGD=1");//Delete sms possition 1
}
void readsmsAT(){
Serial.println("AT+CMGR=1");//Read sms possition 1 AT command
delay(3000);
}
void setup() {
pinMode(indicatorPin,OUTPUT);
delay(12000);//first time connect cable arduino with phone...
Serial.begin(9600);
delay(3000);
Serial.println("AT+CPMS=\"ME\",\"SM\"");//Set memory phone for store sms to SIM
delay(3000);
Serial.println("ATE=0");//Echo off
delay(3000);
}
void loop()
{
readString=0;//format readString...
readsmsAT();//read sms repeatedly
// read phone reply if available
while(Serial.available() > 0)
{
Serial.print( c=Serial.read());
readString+=c;
}
delay(1000);
Serial.println(readString);//serial monitor display sms pdu format
delay(3000);
if ( readString.indexOf("26F37")>0)// pdu on is 26F37
{
digitalWrite(indicatorPin, HIGH);//only for test led on
delay(5000);
digitalWrite(indicatorPin, LOW);//only for test
}
if (readString.length()>40)//delete sms if sms received
{
delsms();//delete sms
}
delay(10000);//delay start loop again for check new sms...
}