Error when sending text messages through sim900a

Hello people!
I have connected sim900a Module with Arduino using proper circuitry. The module works fine when I place a call to any number, but every time I need to send text messages through the module I face an error as shown in the picture attached below. Please help me as I have run out of ideas.

This is the code that I have been running

#include <SoftwareSerial.h>
SoftwareSerial SIM900A(2,3);
void setup()
{
  SIM900A.begin(115200);   // Setting the baud rate of GSM Module  
  Serial.begin(115200);    // Setting the baud rate of Serial Monitor (Arduino)
  Serial.println ("SIM900A Ready");
  delay(100);
  Serial.println ("Type s to send message or r to receive message");
}
void loop()
{
  if (Serial.available()>0)
   switch(Serial.read())
  {
    case 's':
      SendMessage();
      break;
    case 'r':
      RecieveMessage();
      break;
  }
 if (SIM900A.available()>0)
   Serial.write(SIM900A.read());
}
 void SendMessage()
{
  Serial.println ("Sending Message");
  SIM900A.write("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(2000);
  Serial.println ("Set SMS Number");
  SIM900A.write("AT+CMGS=\"+number\"\r"); //Mobile phone number to send message
  delay(2000);
  Serial.println ("Set SMS Content");
  SIM900A.write("Good morning, how are you doing?");// Messsage content
  delay(2000);
  Serial.println ("Finish");
  SIM900A.write(26);// ASCII code of CTRL+Z
  delay(2000);
  Serial.println ("Message has been sent ->SMS Selesai dikirim");
}
 void RecieveMessage()
{
  Serial.println ("SIM900A Membaca SMS");
  delay (1000);
  SIM900A.write("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
  delay(1000);
  Serial.write ("Unread Message done");
 }

Hi
Are really send number as .png image?

1 Like

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project.

No xD
It was a failed attempt to upload the screen shot, Thank You for pointing it out :slight_smile:

you are using software serial which isn't reliable at 115200 baud
try SIM900A.begin(9600);

while I'm at it, change all of your SIM900A.write to SIM900A.println except for this SIM900A.write(26);

FYI, "AT+CMGF=1" can be called once in setup(), you don't have to invoke it over and over each time you send SMS

1 Like

No way can you use Software Serial at that baud rate... try 19200.

If the SIM900A does not auto-detect the baud rate you will also need to ensure that is set to a matching baud rate, by issuing the appropriate AT command.

1 Like

Hey!
I did as you just said I changed the baud rate plus I also changed

the commands, But I get the following on my Serial Monitor.

Thank You man, I have changed the baud rate and still, I get the same error.

Do you know if the SIM900A has auto baud detection? If not it may be running at a different baud than your code.

Try the following sketch...

#include <SoftwareSerial.h>                     

SoftwareSerial softSerial(2,3);


void setup()
{
  Serial.begin (115200);
  softSerial.begin (9600);
}


void loop()
{
  
  while (Serial.available() > 0)
    softSerial.write(Serial.read());

 
  while (softSerial.available() > 0)
    Serial.write(softSerial.read());

}

Try issuing a simple AT command in the serial monitor.

If it doesn't work try changing the baud rate of the SIM900A to match the sketch with a AT+IPR=9600 command.

1 Like

I 've tried just as you said, but all I receive is inverted Question Marks plus the '@' sign :slightly_frowning_face:

Did you try to issue the command to change the baud rate to the modem?

Have you set the baud rate in the monitor to 115200?

yes I did but the response was same

Can you show a screenshot of the monitor window.

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