SIM800L sending SMS issue

Hi I'm new to the forum, and this is my school project. It is involved a SIM800L comm. module. I'm using an Arduino Mini Pro 5V 16Mhz as my microcontroller. I followed the guide from YT and had the SIM800L connected accordingly. I was testing the SIM800L with an examples code and testing the AT commands on the serial monitor. I got it send out all calls, but it could not send out text messages. I attached my code and the result I received. After the AT+CMGS="+1832#######", it did not respond back with anything. Any help or guidance will be appreciated.

my code:
<
#include <SoftwareSerial.h>

SoftwareSerial mySerial(5, 4); // RX, TX

void setup() {
Serial.begin(9600);

mySerial.begin(9600);

}
void loop() {
if (mySerial.available()) {
Serial.write(mySerial.read());
}
if (Serial.available()) {
mySerial.write(Serial.read());
}
} >

The result I got back:
AT
OK
AT+CPIN?
+CPIN: READY
OK
ATD+ +1832#######
OK
AT+CMGF=1

OK
AT+CMGS="1832#######"
/> Hi
/>
/>

I was expecting a response such as +CMGS:# , but nothing showed.

It might be worth reading the AT command reference, or using a pre tested SMS library.

It looks like you’ve missed the last part of sending a text message.

+CMGS… wait for prompt… send text… terminate the message, then you’ll get the OK/ERROR responses

1 Like

You have to terminate the message with a CNTL-Z character. Problem is you can't send this character from the Serial Monitor.

Use the following, and terminate your message with "*". This code will substitute with CNTL-Z before sending to the SIM800.

Instead of

if (Serial.available()) {
mySerial.write(Serial.read());
}

Replace with...

if (Serial.available() > 0) 
{
  char c = Serial.read();
  if c == '*'
   mySerial.write(0x1A);  // Replace with CNTL-Z 
  else
    mySerial.write(c);
}

Thank you so much, this works, but I had to change

if c == '*'

to

if (c == '*')

to compile successfully

Yep... typo on my part.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.