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.

  • \$\begingroup\$ You could control the whole sensor/GSM constellation with an Arduino. \$\endgroup\$
    – Dat
    Commented Oct 29, 2016 at 22:21
  • \$\begingroup\$ @canadiancyborg Sorry I'm not sure I understand but I'm not using any sort of Arduino. I'm using LPC1768 for that matter. I'm looking for ideas not hardware platform. I have a pretty good platform. LPC1768 rocks! \$\endgroup\$
    – mostafanfs
    Commented Oct 29, 2016 at 22:24
  • \$\begingroup\$ I mean that you could replace your LPC1768 with an ATmega328P. It is quite low power consumption. It's low clock speed also lets you save a but of power. An it can easily communicate between multiple sensors and a GSM module. The best part is that the Arduino has a sleep mode that is quite sensitive. As soon as the wake up condition happened, it will do what it is supposed to be done correctly, such as reading an SMS. \$\endgroup\$
    – Dat
    Commented Oct 29, 2016 at 22:29
  • \$\begingroup\$ @canadiancyborg No I don't have problem with MCU. Sure AVR is great but Cortex-M3 in sleep mode consumes even less power then AVR and in normal mode it gives you great power and features. It doesn't matter. It's the GSM module that may lose the SMS not MCU. Cause GSM module is turned off for the most part of it bt MCU. You see Who cares what kind of MCU is being used. I don't have problem with sleep mode. \$\endgroup\$
    – mostafanfs
    Commented Oct 29, 2016 at 22:36

1 Answer 1


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.

  • \$\begingroup\$ Well thanks. Good idea about putting module into sleep. I didn't know that! But for the first part I don't know if issuing AT+CMGR=1 would be right cause new message gets another number if there are already stored messages. Unless I keep deleting messages after receiving and processing them. Still I could not be sure if the message I'm looking for is located in memory index 1. Maybe two messages arrive together and my message gets a different index. \$\endgroup\$
    – mostafanfs
    Commented Oct 30, 2016 at 17:57
  • \$\begingroup\$ @mostafanfs Well, you could set the CNMI settings to send you SMS notifications and not the SMS itself. The notifications usually contain the index of the SMS. Depending on how quickly your MCU can wake up and exactly how long it takes for the module itself to wake and send the notification, you could wake up in time to catch the notification, read the index and extract the actual SMS. Besides, you said its only config settings...SMS frequency shouldn't be that high then. \$\endgroup\$ Commented Oct 30, 2016 at 19:28

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.