SIM900 is not sending a sms

I am new to SIM900 module and my below code is modified from a tutorial and this forum Q&A. I had set the jumper to software serial selected. Unfortunately, my code is not sending out a sms.

Here is my code:

#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
  SIM900.begin(19200);
  
  // For serial monitor
  Serial.begin(19200); 
  // Give time to your GSM shield log on to network
  delay(20000);
  Serial.begin(9600);
  if (SIM900.available())
  {
      Serial.println("SIM 900 is ready");
  }
  else
  {
    Serial.println("SIM 900 is not ready");
  }
  Serial.println("Sending message");
  // Send the SMS
  sendSMS();
}

void loop() {
}
void sendSMS() {

  SIM900.println("AT");
  String status_code = SIM900.readStringUntil("64");  // Read string until 64 is found (end of message
  Serial.print("Sim responds = ");
  Serial.print(status_code);
  // AT command to set SIM900 to SMS mode
  SIM900.print("AT+CMGF=1\r"); 
  delay(100);

  status_code = SIM900.readStringUntil("64");  // Read string until 64 is found (end of message
  Serial.print("Sim responds = ");
  Serial.print(status_code);

  SIM900.print("AT+CMEE=1\r"); 
  delay(100);

  status_code = SIM900.readStringUntil("64");  // Read string until 64 is found (end of message
  Serial.print("Sim responds = ");
  Serial.print(status_code);

  SIM900.print("AT+CSCS=\"GSM\"\r"); 
  delay(100);

  status_code = SIM900.readStringUntil("64");  // Read string until 64 is found (end of message
  Serial.print("Sim responds = ");
  Serial.print(status_code);


  SIM900.print("AT+CSTA?\r"); 
  delay(100);

  status_code = SIM900.readStringUntil("64");  // Read string until 64 is found (end of message
  Serial.print("Sim responds = ");
  Serial.print(status_code);
  
  SIM900.print("AT+CSQ\r"); 
  delay(100);

  status_code = SIM900.readStringUntil("64");  // Read string until 64 is found (end of message
  Serial.print("Sim responds = ");
  Serial.print(status_code);

  SIM900.print("AT+CMGS=\"0194802873\""); 
  SIM900.print("\r");
  delay(100);
  status_code = SIM900.readStringUntil("64");  // Read string until 64 is found (end of message
  Serial.print("Sim responds = ");
  Serial.print(status_code);
  
  SIM900.println("Message example from Arduino Uno."); 
  delay(100);

  // End AT command with a ^Z, ASCII code 26
  SIM900.println((char)26); 
  SIM900.print("\r\n"); // Send CRLF
  delay(100);
  SIM900.println();
  // Give module time to send SMS
  delay(5000); 
  Serial.println("Message sent");
}

The output is as follow:

11:44:27.523 -> SIM 900 is not ready
11:44:27.523 -> Sending message
11:44:28.563 -> Sim responds = AT
11:44:28.563 -> 
11:44:28.563 -> OK
11:44:29.683 -> Sim responds = AT+CMGF=1

11:44:29.683 -> OK
11:44:30.803 -> Sim responds = AT+CMEE=1

11:44:30.803 -> OK
11:44:31.923 -> Sim responds = AT+CSCS="GSM"

11:44:31.923 -> OK
11:44:33.003 -> Sim responds = AT+CSTA?

11:44:33.003 -> +CSTA: 129
11:44:33.043 -> 
11:44:33.043 -> OK
11:44:34.123 -> Sim responds = AT+CSQ

11:44:34.123 -> +CSQ: 18,0
11:44:34.123 -> 
11:44:34.123 -> OK
11:44:35.243 -> Sim responds = AT+CMGS="0194802873"

11:44:35.243 -> > Message sent

what did I make wrong in the above code? if you spot my errors, please point out my errors. Thank you in advance.

Most issues we have seen with GPRS boards that don’t work as expected when using codes from published examples is due to using an insufficient power source.

Can you describe how things are wired and powered?

I am using an external power supply with 5v and 1amp to the sim900 module power socket. For my arduino board, the power is from my laptop usb port. The pin 7 and 8 are for tx and rx respectively. That is my wiring and settings.

For the pin 7 and 8, i am following this url article, https://lastminuteengineers.com/sim900-gsm-shield-arduino-tutorial/

Is my power source enough to run my simple sms messaging service?

usually it's recommended to go for 2 amps. Do you have any specification for your module? (which one do you have?)

No, my sim 900 modulr does not come with any document. I shall increase the amp and test it out later. Thanks for your feedback.

Are you sure the sim900 works with your network? Does the SIM have credit?

My sim has sufficient credit and tested on my phone. Sim 900 status and netlight led are lighted up or blinking once I power up and press power key button for short moment.

What is the "64" in this statement? It is supposed to be a terminating CHARACTER.

You will get compiler warnings about this if you turn them on

/var/folders/4z/3g9th3gs4cng3b803dg5bhw40000gn/T/arduino_modified_sketch_152933/HelloWorld.pde: In function 'void sendSMS()':
/var/folders/4z/3g9th3gs4cng3b803dg5bhw40000gn/T/arduino_modified_sketch_152933/HelloWorld.pde:31:51: warning: invalid conversion from 'const char*' to 'char' [-fpermissive]
   String status_code = SIM900.readStringUntil("64");  // Read string until 64 is found (end of message
      

Have you tried with a simple passthrough sketch?

I got the compilation warning message but do not think it will impact sending sms though. Fyi, I copied readStringUntil statement from an article and my purpose is only dumping after at command results.

When I copied sending sms code, I only set initializing baud rate,sms mode, recipient mobile no, message and terminate message character. No reading statement was added. After i could not send a simple sms, i only added more at command in the beginning and tried to dump out the at command operation result to a console screen to rule out wiring and any other possible issues.

a few more AT commands worth trying
AT+CGMI returns the manufacturer's name
AT+CGMM returns the MODEM model number
AT+CGMR returns details of the software and model revision level
AT+CGSN returns the MODEM's serial number
AT+CIMI returns IMSI of the SIM card
AT+CCID returns the SIM ID number
AT+CNUM returns your telephone number

Have you tried sending an SMS to the modem?

Hi, what power supply are you using?

...

Usually they need 5V, 2A. Is your SIM900 being registered to the network? Is the network LED blinking after every 3 seconds?

You should read the thread...

My power source is 5v and max output is 5amp and test again. The sending sms is still not working. I do not implement reading sms as it is not part of my project.

I have done following operation.
AT+CGMI, AT+CGMM, AT+CGMR, AT+CGSN, AT+CIMI, AT+CCIDnumber and
AT+CNUM

the above results are following:
10:39:23.058 -> Sim responds = AT+CGMI

10:39:23.058 -> SIMCOM_Ltd
10:39:23.058 ->
10:39:23.058 -> OK
10:39:24.178 -> Sim responds = AT+CGMR

10:39:24.178 -> Revision:1137B08SIM900M64_ST_DTMF_JD_MMS
10:39:24.213 ->
10:39:24.213 -> OK
10:39:25.273 -> Sim responds = AT+CGSN

10:39:25.273 -> 012207000000015
10:39:25.308 ->
10:39:25.308 -> OK
10:39:26.393 -> Sim responds = AT+CGMM

10:39:26.393 -> SIMCOM_SIM900
10:39:26.393 ->
10:39:26.393 -> OK

These commands, AT+CIMI, AT+CCIDnumber and
AT+CNUM, return some information to my console screen and cell phone no is correct.

In your opinion, what can I test or try to rule out my possible mistakes?

... but why don't you try it... just to see if it is received. That will prove that the modem it capable of SMS on the network.

Did you try this? Like this...

#include <SoftwareSerial.h>

SoftwareSerial modem(7, 8);


void setup()
{
  Serial.begin(19200);
  modem.begin(19200);
  
  delay(100);

  Serial.println("Starting");
}


void loop()
{
  while (Serial.available())
  {
    char c = Serial.read();
    if (c == '*')
      modem.write(char(26));
    else
      modem.write(c);
  }

  while (modem.available())
  {
    Serial.write(modem.read());
  }
}

i got it working now and it is my sim card is not working with sim900. thanks for all inputs and helps and have a good day.

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