user23686: 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

user28033: 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

23686: <p>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.</p>

<pre><code>#include &lt;avr wdt.h=""&gt;  
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() &gt; 0)  
{  
char inChar = Serial.read();  
if (inChar != '\r')  
{  
result[i] = inChar;  
i++;  
}  
}  
return result;  
}  
</code></pre>

<p>output is look like this:
AT+CMGF=1  </p>

<p>OK  </p>

<p>AT+CNMI=2,2,0,0,0  </p>

<p>OK<br>
AT+CMGL="ALL"  </p>

<p>OK</p>
 28033: <p>Check you sim card inbox. I also had the same problem, and it turns out the sim card sms inbox capacity is full.<br>
You can also try to use another library, here is one of <a href="https://github.com/Seeed-Studio/GPRS_SIM900" rel="nofollow noreferrer">them</a></p>
