2

Here I am using Arduino uno and GSM sim900A, I want to read sms from sim900A. But i am trying to read message, it is showing the empty values. I tried different methods, but no use. Here I have added my script. Please help me.

#include <avr wdt.h=""> 
String phoneSMS = "+91xxxxxxxxxx"; 
String messageTxt; 
void setup() 
{ 
Serial.begin(9600); 
delay(60000); 
srl_msg(); 
} 
String srl_msg() 
{ 
Serial.println("AT+CMGF=1\r"); 
delay(1000); 
Serial.println("AT+CNMI=2,2,0,0,0"); 
delay(1000); 
Serial.println("AT+CMGL=\"ALL\"\r"); // to read ALL the SMS in text mode 
delay(1000); 
char txtmsg2[100]; // AT command output 
String date = readSerial(txtmsg2); 
String value = date.substring(1, 50); 
messageTxt = "Internal - Heart Beat;"; 
messageTxt.concat(value); 
Serial.println(value); 
SendSMS(messageTxt); 
} 
void loop() 
{ 
} 
void SendSMS(String message) 
{ 
Serial.print("at+cmgf=1\r"); 
delay(1000); 
Serial.print("at+cmgs=\""); 
Serial.print(phoneSMS); 
Serial.println("\""); 
delay(1000); 
Serial.println(message); 
delay(1000); 
Serial.print((char)26); 
delay(15000); // AAN 
} 
String readSerial(char result[]) 
{ 
int i = 0; 
while (Serial.available() > 0) 
{ 
char inChar = Serial.read(); 
if (inChar != '\r') 
{ 
result[i] = inChar; 
i++; 
} 
} 
return result; 
} 

output is look like this: AT+CMGF=1

OK

AT+CNMI=2,2,0,0,0

OK
AT+CMGL="ALL"

OK

asked Jul 7, 2016 at 6:49

2 Answers 2

1

Check you sim card inbox. I also had the same problem, and it turns out the sim card sms inbox capacity is full.
You can also try to use another library, here is one of them

answered Nov 10, 2016 at 3:44
0

wdt.h is just time handling data library, and have no methods for send or receive sms...

Your method: SendSMS(String message)

is just printing serial labels and counting a char that you are putting in the serial monitor.

Try this GSM example...

answered Sep 21, 2016 at 16:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.