I am using an Arduino UNO R3 and an IComsat v1.1 SIM900 shield with the library I found here:http://code.google.com/p/gsm-shield-arduino/
which I think is what a lot of other people are using too.
I want to build a device that I can program by sending text messages, so it should see when a new message arrives. I am sending text messages and they arrive fine, but some of them are not being recognized as new messages. But they are there, I can actually read them out.
This is my code:
int num, k;
long int com;
for (k = 1; k <= 20; k++) // free up first 20 positions of messages on SIM card
if(sms.GetSMS(k, n, smsbuffer, 160)) sms.DeleteSMS(k);
if (Serial.available() > 0)
com = Serial.read();
if (com == 'x') Serial.println("Hello");
if (num = sms.IsSMSPresent(SMS_UNREAD))
Serial.println ("New SMS!");
Serial.print ("Number: ");
When I am sending messages from my cell phone I obtain the following output at the serial monitor:
So number 3 and 4 are not being recognized as new messages here.
Surprisingly I found that when I remove the few lines where I read the serial port just at the begin of the loop function, it works better, i.e. less messages are skipped. That's why I kept it here in this code.
Is anyone able to explain to me what the problem is and how I can fix this?
Thanks a lot for your input,