GSM module SIM 900 Problem to send SMS (FIXED VERSION)

Hello !

I tried the program you sent me (with and without removing the first 0 from my phone number because french telephony works differently), but it still didn't work.

I first started without the first 0, and here's the result I got:

image

And then I compiled by adding the first 0:

image

In both case when I display the serial monitor to try this program, the Netlight LED will blink every 3 secondes, but I still didn't receive any message.

I also tried again by modifying the program a little and replacing "number" by "DestinationNumber" and "message" by "SMSMessage" for the last code snippets:

#include <SoftwareSerial.h>

SoftwareSerial ATCommandStream(7, 8);
unsigned long ATComandBaudRate = 9600;

const char * DestinationNumber = "+33686920417";
const char * SMSMessage = "Bonjour";

void setup()
{
  // start th serial communication with the host computer
  Serial.begin(115200);
  while (!Serial);
  delay(200);
  Serial.println("Sketch started.");

  // Power up the SIM900
  pinMode(9, OUTPUT);
  digitalWrite(9, LOW);
  delay(1000);
  digitalWrite(9, HIGH);
  delay(2000);
  digitalWrite(9, LOW);
  delay(3000);

  ATCommandStream.begin(ATComandBaudRate);
  Serial.print("ATCommandStream started at baud rate ");
  Serial.println(ATComandBaudRate);


  SendShortCommand("AT"); // Just checking that it responds with OK
  SendShortCommand("AT+CMEE"); // Turn on verbose messages

  SendShortCommand("AT+CSQ"); //Signal quality test, value range is 0-31 , 31 is the best
  SendShortCommand("AT+CCID"); //Read SIM information to confirm whether the SIM is plugge
  SendShortCommand("AT+CREG?"); //Check whether it has registered in the network

  SendShortCommand("AT+CSCS=\"GSM\""); // Set character set to GSM
  SendShortCommand("AT+CSTA?");  // Check the phone number type
  Serial.println("Note: 129=Unknown, 161=National, 145=International, 177=Network Specific");

  SendSMSMessage(DestinationNumber, SMSMessage);

  SendShortCommand("AT"); // Just checking that it still responds with OK
}

void loop() {}

bool WaitForResponse()
{
  unsigned long startTime = millis();
  while (millis() - startTime < 5000)
  {
    String reply = ATCommandStream.readStringUntil('\n');
    if (reply.length() > 0)
    {
      Serial.print("Received: \"");
      Serial.print(reply);
      Serial.println("\"");

      if (reply.startsWith("OK"))
        return true;

      if (reply.startsWith("ERROR"))
        return false;
    }
  }

  return false;
}

bool SendShortCommand(String command)
{
  Serial.print("Sending command: \"");
  Serial.print(command);
  Serial.println("\"");

  ATCommandStream.print(command);
  ATCommandStream.print("\r\n");

  if (WaitForResponse())
  {
    return true;
  }
  else
  {
    Serial.print("ERROR or timeout waiting for response to \"");
    Serial.print(command);
    Serial.println("\"");
  }
  return false;
}

void SendSMSMessage(const char *DestinationNumber, const char *SMSMessage)
{
  Serial.println("Sending SMS text");

  if (!SendShortCommand("AT + CMGF = 1")) // Set the SMS output to text mode
  {
    Serial.println("Error in CMGF = 1 (setting to text mode)");
    return;
  }

  if (!SendShortCommand("AT + CMGS = ? ")) // Test for CMGS command support:
  {
    Serial.println("Error in CMGS = ? (testing for CMGS support)");
    return;
  }

  Serial.print("Sending : ");
  Serial.print("AT + CMGS = \"");
  Serial.print(DestinationNumber);
  Serial.println("\"(CR)");
  Serial.print(SMSMessage); // The SMS text you want to send
  Serial.println("(EM)");

  ATCommandStream.print("AT+CMGS=\"");  // Send SMS
  ATCommandStream.print(DestinationNumber);
  ATCommandStream.print("\"\r"); // NOTE: Command ends with CR, not CRLF
  ATCommandStream.print(SMSMessage); // The SMS text you want to send
  ATCommandStream.write(26); // ASCII EndMessage (EM) CTRL+Z character

  if (!WaitForResponse())
    Serial.println("ERROR or timeout waiting for response to CMGS command");
}

But still the same problem and here's what I got without the first 0 of my phone number:

image

Is there a problem related to what I obtain in the serial monitor ?

Thanks in advance if you have an idea...