SIM800L First SMS Sending Issue In a Row of Pulse Triggers

On the project that we are currently developing, a SIM800L module is used.

Our device is only programmed to send an SMS when it gets a 5V digital pulse to microprocessor’s input (Arduino Nano).

The issue is about sending first SMS.

In intensive use, SIM module can send SMS for every single pulse applied to Arduino’s input but when it is set aside and after a while pulses applied, the first pulse is missing and no SMS sending.

For instance, if I set the device aside and after 1 hour if I apply 5 pulses, SIM module sends 4 SMSs (first one is missing sometimes).

So SIM module working as like its in sleep mode whether there is no AT command has been uploaded to set it in sleep mode. But sometimes first pulse in a daily usage is missing.

*Note: a1000uF capacitor has been soldered to Vcc and GND of SIM module but the problem still continues. Sometimes it does send the first SMS in a row of pulses but sometimes not.

Hello and welcome! Can you give us an idea of the sequence of AT commands you send after each pulse?

Hello,

im sharing a part of the program below X X phone numbers are entered by a keypad and saved in eeprom.

In void loop:

    if(digitalRead(inPin)==HIGH)
          { 
            
              mySerial.println("AT"); 
              updateSerial();
              mySerial.println("AT+CMGF=1"); 
              updateSerial();
              mySerial.println(kod2N);  // kod2N={'A','T','+','C','M','G','S','=','"','+','9','X','X','X','X','X','X','X','X','X','X','"'};
              updateSerial();
              mySerial.print("TEXT TEXT TEXT.."); //text content
              updateSerial();
              mySerial.write(26);
    }

Function for serial update:

void updateSerial()
{
        delay(2000);
        while (Serial.available()) 
        {
          mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
        }
        while(mySerial.available()) 
        {
          Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
        }
}

this code runs normally, in serial monitor everything and every respond seems normal but sometimes after a while first sms is missing.
thanks.

Do you receive any error or particular message from your updateSerial() function when the first sms fails to be send?

No, there is no Error message. It looks same respond whether the SMS has been sent or not.

On the serial monitor;

////not recieved SMS
OK
AT
OK
AT+CMGF=1
OK
AT+CMGS=”+9XXXXXXXXXXX”
> SMS TEXT SMS TEXT….

////received SMS
OK
AT
OK
AT+CMGF=1
OK
AT+CMGS=”+9XXXXXXXXXXX”
> SMS TEXT SMS TEXT….

The first sent message pretends to take the module out of sleep mode. But there is no command for sleep mode and also this issue is not happening always.

According to the AT Commands document from the manufacturer, in the example on page 361 under the tittle “SMS Commands”, you should receive an OK after you close the message with “Ctrl+Z”. You can check this by adding an aditional updateSerial() after the mySerial.write(26);

Since your code doesn’t check if the previous command has been received properly before sending a new command, maybe at some point the software gets de-syncronized with the actual state of the SIM800.

I added one more updateSerial() after mySerial.write(26) but its still same.

OK
AT

OK
AT+CMGF=1

OK
AT+CMGS="+9xxxxxxxxxxx"

> SMS TEXT SMS TEXT…
+CMGS: 182

OK
AT

OK
AT+CMGF=1

OK
AT+CMGS="+9xxxxxxxxxxx"

> SMS TEXT SMS TEXT…  //this hasn't been received
+CMGS: 183

OK
AT

OK
AT+CMGF=1

OK
AT+CMGS="+9xxxxxxxxxxx"

> SMS TEXT SMS TEXT…

I’ve started to use it by adding one idle phone number section in order to avoid missing sms’s.

          mySerial.println("AT"); 
          updateSerial();
          mySerial.println("AT+CMGF=1"); 
          updateSerial();
          mySerial.println("AT+CMGS=\"+901111111111\""); //idle phone number
          updateSerial();
          mySerial.print("SMS text SMS text.."); 
          updateSerial();
          mySerial.write(26);          
          updateSerial();          
          
          
          delay(5000);
          mySerial.println("AT+IPR=9600");
          updateSerial();
          delay(3000);

          mySerial.println("AT"); 
          updateSerial();
          mySerial.println("AT+CMGF=1"); 
          updateSerial();
          mySerial.println(kod2N); //includes real phone number
          updateSerial();
          mySerial.print("SMS text SMS text.."); 
          updateSerial();
          mySerial.write(26);       
          updateSerial();

And does this work ok?

I still see a weird pattern on the responses you receive. Shouldn’t you start with a AT<CR LF>OK<CR LF> instead of a <CR LF>OK<CR LF>AT ? If the module is responding to all your commands, I don’t think you can say it is in a sleep mode of some kind.

there are still lost messages but less than the previous situation.

+CMGS: 231
OK

AT
OK

AT+CMGF=1
OK

AT+CMGS="+901111111111"  //idle number
> TEXT SMS TEXT SMS..
ERROR

AT+IPR=9600
OK

AT
OK

AT+CMGF=1
OK

AT+CMGS="+9xxxxxxxxxxx" //real number
> TEXT SMS TEXT SMS..

command responds actually seem like this.

Is there a reason why you need to switch bauds when you have already established UART communication?

Maybe the problem is electrical…

  • How are you powering the SIM800?
  • Have you setup a logic level shifter between the Arduino’s UART and the SIM800 UART, or does your module take care of that for you (if so, how?)?
AT+IPR=9600 
OK

I’ve already deleted this line, its useless, it makes no effect on it.

For the power source; a 9V 2A adapter is used. Arduino Nano and LM2596 buck converter are powered up by that adapter.

4.1V (from converter) is applied to SIM800 and voltage divider with 10k and 20k resistors to feed Rx terminal between D2 of the Nano and GND.
Tx is directly connected to D3 of the Nano.

Ok, on this document on page 32 the manufacturer shows a simple circuit to properly interface the SIM800 with a 5v microcontroller. Keep in mind that VDDEXT is 2.8v.