Electrical – Receive SMS from GSM module in a battery powered system

batteriesgsm

The title is pretty clear. I'm working with a GSM module (SIM908) and the whole system is powered by a battery and is supposed to work for a pretty long time.
The system gets a sample from a sensor every 2 hours or so and send all taken samples every day using SMS. In the mean time it goes to sleep so nothing is working and thus I can not receive any messages from GSM.
I want to send some settings and configs by my phone using SMS to a system that is in sleep in the moment.

In a normal system where there is power all the time I can read and process received messages using AT commands but in a battery powered system I'm not sure what exactly to do.
Cause I wake up system for a pretty small time just to send data but how can I receive SMS that I have sent maybe couple hours before right in that time while I'm NOT planning on keeping system on for a long time? (I mean I can't wait to receive messages forever)

Unfortunately there are no AT commands to give me the number of received and stored messages so I would be able to turn on the system for a couple of minutes and loop over those number of stored messages to find the message I'm looking for.

there is just a AT+CMGL="REC UNREAD" command but it gives the whole messages including their indexes, their numbers, their time-date, their contents and everything in response which is not very nice for me. It would be better if I knew the number of total messages instead and then I could simply loop over that number of messages. Something like hey dude there are 12 messages in module memory.

BUT what if turning system on for a couple of minutes was not enough and I lost my message somehow or the network hasn't delivered it to the GSM module yet? What do I do then?

I couldn't thing of something else but to turning on the system every day for a couple of minutes and then process stored messages if there is any. But like I said what if those minutes were not enough for the GSM module to receive messages? GSM is like cancer to a battery and I can not keep GSM online forever or for a long time.

So what is the best way to ensure that a sleepy system will receive a SMS correctly? And it doesn't matter if it gets it that very day or the day after. But I can send a SMS as a feedback to the sender so he will know that the system did recieve the messages finally (It's a good idea!).
I hope I was able to make my point.

Best Answer

I dont think there's any command or built-in method to get the number of unread SMS like you want. The RING pin can be used as an indicator of incoming SMS or calls. You could set up an external interrupt to wake the MCU on the falling edge of the RING pin. The pin stays low for 120ms before returning HIGH. Then you can read the SMS with AT+CMGR=1.

As a bonus, you can put the module itself in sleep mode by sending AT+CSCLK=1 and then raising the DTR line HIGH. This should reduce current consumption significantly. When an SMS comes in, it wakes up automatically and the RING pin sends a pulse that can be used to wake the MCU as explained earlier. You can also wake the module yourself by pulling DTR LOW. Read the hardware design manual for more details.