SIM 900 GSM Module issues with Arduino uno

SIM 900 GSM Module issues with Arduino Uno: it's not sending this SMS message.
the code which I used from a different forum discusion of the same topic

#include <SoftwareSerial.h>

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

const char * DestinationNumber = "+353894877478";
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 *number, const char *message)
{
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(number);
Serial.println(""(CR)");
Serial.print(message); // The SMS text you want to send
Serial.println("(EM)");

ATCommandStream.print("AT+CMGS=""); // Send SMS
ATCommandStream.print(number);
ATCommandStream.print(""\r"); // NOTE: Command ends with CR, not CRLF
ATCommandStream.print(message); // 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");
}

Please autoformat the code, mark it och using code tags, the </> symbol and paste.
The screen shop is unreadable. Copy serial monitor output and paste it in code tags here.

All is here: How to get the best out of this forum - Using Arduino / Installation & Troubleshooting - Arduino Forum

If you look at this link to a forum on this, it will be easier as all the code needed is there, making it much easier to look at. its post no#6

Do you have the SIM900 connected to pins 7 & 8 of the Uno?

Do you have a common GND between the Uno and the SIM900?

SIM900   Uno   
------   -----
Tx.      Pin 7(Rx).
Rx.      Pin 8(Tx).
GND.     GND.

YES

i did the wiring according to Lastminuteengineers
]

You don't appear to have pin 9 connected. Are you powering the SIM900 on manually?

Have you got software UART selected ?

image

I also tried it with pin 9 but the same result I don't know what to do with software UART.

yes I am powering it separately although once testing is complete I am providing power from the power supply to both Arduino and the gsm

That board can communicate either via pin 0/1 (hardware serial), or via pins 7/8 (software serial). You are using Software Serial - you need to ensure the jumper on the board is in the correct position (as shown in the post #8).

I have tried with pins 0/1 and still no luck could either the gsm or Arduino be at fault or can the gsm 900 not support 4g sim cards

As I understand the SIM900 is a 2G modem... but regardless you should still be able to communicate with it.

Ok I’m starting to think maybe my Arduino or GSM might be faulty

I am using the gsm as a part of my project the main part of it is to monitor current flow using a CT but another issue with that is that even when the CT is off and no current is flowing the Arduino still picks up noise from the analog input it also does this when the CT is on and senses current.

I have a Voltage divider in place from the CT wires which connects to the GND and in this case Analog A5 how can I fix this?

Ok so I can get the AT commands to work and it comes back”ok” for the commands but the sms won’t send

Did you see post #13? Does you network provider support 2G ?

Ok I’ll try and set the SIM card to 2G

I was told that if it’s not being powered properly that the gsm will keep try to get to the network but will reset and try again in a loop could this be the case I am supplying it with 3A

If that is occurring you will continually receive startup messages.

Have you tried sending commands manually with a sketch like the following...

#include <SoftwareSerial.h>

#define BAUD 9600

SoftwareSerial softSerial (7, 8);  // Rx, Tx as required.


void setup()
{
  Serial.begin(BAUD);
  softSerial.begin(BAUD);

  Serial.print("Ready @ ");
  Serial.print(BAUD);
  Serial.println(" baud");
}


void loop()
{
  while (Serial.available() > 0)
  {
    char c = Serial.read();

    if (c == '*')
        softSerial.write(0x1A);  
      else
        softSerial.write(c);
  }

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

I’ll try that code and see how I get on thanks