GSM Module does not accept AT commands

Hello, everyone! This is my first topic and hopefully will be the last. I am having troubles setting up the GSM module for our invention.

Problem: The GSM Module does not receive AT commands and does not respond with an OK.

What devices I am using: Arduino ATMEGA2560, SIM900A (GSM Module)

I have connected all the appropriate connections like so:
GSM Module, 5VR ---> Arduino ATMEGA2560, Pin 11 (Yellow, Jumper Wire)
GSM Module, 5VT ---> Arduino ATMEGA2560, Pin 10 (Orange, Jumper Wire)
GSM Module, VCC ---> TTL-to-USB, 5V (Red, Jumper wire)
GSM Module, GND ---> TTL-to-USB, GND (Black, Jumper wire)

I am cheerful to know that everything lights up as it should. So I proceeded to type my code:

#include <SoftwareSerial.h>

#define SerialTransmit_pinout 11
#define SerialReceive_pinout  10

SoftwareSerial gsmMod_obj(SerialReceive_pinout, SerialTransmit_pinout, false);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  gsmMod_obj.begin(9600);
  gsmMod_obj.listen();
  delay(1000);
  Serial.println("GSM Module. Params:\n - Arduino Pin R = 10, T = 11\n - GSM Pin R = 5VR, T = 5VT\n Serial_BaudRate: 9600");

}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()){
    Serial.write(gsmMod_obj.read());
  }

  if(gsmMod_obj.available()){
    Serial.println("Theoretically ready.");
    gsmMod_obj.write(Serial.read());
  } else {
    Serial.println("GSM Module, not available. Rechecking...");
  }
  
  delay(2000);
}

As you can see, I have initialized an object for the GSM Module with inverse_logic to false and added some conditionals if available() returns a value (I assume) other than zero.

After sorting out the code and hardware, I have finally executed the code. This is where it all gets finicky:

available() returns zero and so the code under else gets executed hence, "GSM Module, not available. Rechecking...".

What I have tried:
- Setting the baud rate for the GSM Module to 19200. Because apparently, the internet says so and because it is also where the GSM Module is most responsive. (Did not work)
- Copying and pasting other people's code. (Did not work)
- Connecting the extra VCC and GND from the GSM Module to the Arduino. (Did not work)
- Tried pin 1 and 0 (Rx and Tx pin for MEGA2560), it interfered the uploading process. (Did not work)
- Tried the 3V I/O, 3VR and 3VT. (Did not work)
- Connected GSM Module to 3V supply. (Did not work)
- Changing between SIM cards. (Did not work)

Then finally, I reworked the code; changed all of my jumper wires and turned the devices off and on and still, it did not function.

I appreciate the feedback and scrutiny that will come, thank you.

Hi @ronald826

welcome to the arduino-forum.

Are you sure that everything is wired right?
The message in the serial monitor says
image

Your code says

???

is only true if you have send some bytes from your computer to the Arduino-Mega

As you are using an arduino-mega which has 3 hardware serial ports
I would immidiately change to a hardware-serial.

This condition is only true if the GSM-modem has already sent mimimum one byte to the arduino Mega

As a start you should simplify your code as much as possible:

a simple loop that does send a hardcoded sequence of a command that is known for that your GSM-module will allways answer to it.
And send this hardcoded character-sequence once every five seconds

best regards Stefan

1 Like

Thank you for your reply, Stefan! Everything has been wired right. I mistakenly uploaded an outdated image. I have revised my code but still. Thank you also for clarifying the specific functions in the SoftwareSerial library. As for your recommendation of using HardwareSerial, I will certainly do so. I will reply back to you as soon as I can.

I tried:

 gsmMod_obj.println("AT");    // New code
 delay(5000);                             //

  if(gsmMod_obj.available()){
    Serial.println("Theoretically ready.");
    gsmMod_obj.write(Serial.read());
  } else {
    Serial.println("GSM Module, not available. Rechecking...");
  }

Though, if you can, can you send me some documentation regarding the HardwareSerial Library? Maybe its implementation is similar to SoftwareSerial?
Because I haven't seen some any documentation regarding to HardwareSerial in the Arduino Documentation Website.

What I do know is I don't have to explicitly define which pins because the it is already encoded in the library (pin 1 and 0 by default).

Your feedback has been greatly appreciated.

Okay, digging a little bit deeper into the depths of Google, I just found out that the TTL-to-USB I was using was only delivering current of up to 500 mili-amps but the needed current for data transmission was 2 amperes. This might be the culprit I have been dealing. (If someone can, please close this thread/topic.)

According to manufacturer specs:

The doc speaks of in a transmit burst which typically rises to 2A
If this is a current-spike that occurs only for a short time
you could give adding two 4700µF capciators that are connected as close as possible to the modem a chance

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