I've used SIM800L cheap module for arduino project. System is controled via SMS, and I have a huge problem.
After sending 2 or more SMS to Arduino system kinda blocks. Here's whats happening:
After sending 2 or more SMS instantly SIM module block and last message goes stuck in SIM memory and every loop the same comand is given (according to last SMS)
This is a huge problem, did anyone has similar problem?
Have you read and delete the received SMSes? The storage for the SMS is limited. Have you checked how many SMS are stored in the module? If possible you should read out a received SMS and delete it immediately afterwards.
pylon:
Have you read and delete the received SMSes? The storage for the SMS is limited. Have you checked how many SMS are stored in the module? If possible you should read out a received SMS and delete it immediately afterwards.
@pylon I'm using SIM900IDE library and in the library code there is a line that delete all messages after reading, and that's not the problem. When I send the comand via SMS and everything is working OK, arduino reads message, do the comand given and than delete the message.
But for exapmle if there is no coverage and I send 3 SMS messages, and when the sim module receive all 3 SMS at the same time it goes stuck and it's always sending one message to arduino all over again. And then arduino is doing the same thing in every loop.
You get the problem?
Is it prossible that the sim module isn't good enough or you think it's something in the code thats wrong?
But for exapmle if there is no coverage and I send 3 SMS messages, and when the sim module receive all 3 SMS at the same time it goes stuck and it's always sending one message to arduino all over again.
The module might get all three messages at once. The Arduino (should) only ask(s) it for one at a time.
and it's always sending one message to arduino all over again. And then arduino is doing the same thing in every loop.
You get the problem?
Is it prossible that the sim module isn't good enough or you think it's something in the code thats wrong?
Do you want me to post the code that process the SMS?
No. You need to post ALL of the code.
In the library, in code there is no such command.
No such command as what? The library should have a method to return the number of messages, to return one of the messages, and to delete one, or all, of the messages.
I can't. That location is NOT where you got the library. Post a link, AS A LINK (use the 12th icon from the left), to that location.
Correct me if I'm wrong but I think that the library sould delete the message after procesing it?
I don't think that that is a reasonable assumption. My phone doesn't delete text messages just because I read them. I would be surprised, and pissed, if the library did that.
PaulS:
I can't. That location is NOT where you got the library. Post a link, AS A LINK (use the 12th icon from the left), to that location.
Sorry for the mistake, here is the link for the library:
PaulS:
I don't think that that is a reasonable assumption. My phone doesn't delete text messages just because I read them. I would be surprised, and pissed, if the library did that.
Here's the code from the sms.h file from the library for deleting the message after processing it:
/**********************************************************
Method deletes SMS from the specified SMS position
position: SMS position <1..20>
return:
ERROR ret. val:
---------------
-1 - comm. line to the GSM module is not free
-2 - GSM module didn't answer in timeout
-3 - position must be > 0
OK ret val:
-----------
0 - SMS was not deleted
1 - SMS was deleted
**********************************************************/
char SMSGSM::DeleteSMS(byte position)
{
char ret_val = -1;
if (position == 0) return (-3);
if (CLS_FREE != gsm.GetCommLineStatus()) return (ret_val);
gsm.SetCommLineStatus(CLS_ATCMD);
ret_val = 0; // not deleted yet
//send "AT+CMGD=XY" - where XY = position
gsm.SimpleWrite(F("AT+CMGD="));
gsm.SimpleWriteln((int)position);
// 5000 msec. for initial comm tmout
// 20 msec. for inter character timeout
switch (gsm.WaitResp(5000, 50, "OK")) {
case RX_TMOUT_ERR:
// response was not received in specific time
ret_val = -2;
break;
case RX_FINISHED_STR_RECV:
// OK was received => SMS deleted
ret_val = 1;
break;
case RX_FINISHED_STR_NOT_RECV:
// other response: e.g. ERROR => SMS was not deleted
ret_val = 0;
break;
}
gsm.SetCommLineStatus(CLS_FREE);
return (ret_val);
}
sorry for confusion. I look more into GSM library and my code. I do not call DeleteSMS(), GetSMS() and isSMSPresent() functions.
I am just using readSMS() which is doing all of that together:
boolean SIMCOM900::readSMS(char* msg, int msglength, char* number, int nlength)
{
long index;
_tf.setTimeout(_GSM_DATA_TOUT_);
_cell << "AT+CMGL=\"REC UNREAD\",1" << endl;
if(_tf.find("+CMGL: ")) // if sms present
{
index=_tf.getValue();
_tf.getString("\"+", "\"", number, nlength);
_tf.getString("\n", "\nOK", msg, msglength); // get sms
_cell << "AT+CMGD=" << index << endl; / delete sms
_tf.find("OK");
return true;
};
return false;
};
Is there a benefit to use isSMSPresent(), getSMS() and deleteSMS() instead this function? Anyway I will try if that can resolve my problem with receiving 3 SMS at the same time.
Is there a benefit to use isSMSPresent(), getSMS() and deleteSMS() instead this function?
I would think that the fact that the function is flagged as deprecated would be sufficient.
I would also think that you could have tried using the three methods, instead of the one, and determined whether or not there was an improvement in the overall process, in less time than it would have taken to argue that the one function does it all.
Paul, i would like to thank you for helping me, now everyting is working more than fine. I've used the metods you suggested and none of the problems occurs anymore.
Thank you again for your time and help!
Cheers!