Electrical – No communication with SIM900A using Arduino Uno

arduinogsmserialsim900wireless

I am using Arduino Uno and trying to connect to a SIM900A GSM module using serial communication. I am not receiving anything from the module at all. The module powers on and has another LED flashing at 800ms

I have connected the following

  • 5V from Arduino to 5V power supply input on GSM

  • GND from Arduino to GND power supply input on GSM

  • Pin 2 (Rx) from Arduino to Tx serial on GSM

  • Pin 3 (Tx) from Arduino to Rx serial on GSM

  • GND from Arduino to GND serial on GSM

Breakout-board schematic from this page.

enter image description here

I have tried both Arduino's built in serial comm and also software serial using pins 2 and 3.

Information about SIM900 can be found here.

picture of the module

The code that I am currently running, using software serial:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3);

const int baud = 9600;

void setup() {
  mySerial.begin(baud);
  Serial.begin(baud);

  while (mySerial.available() < 0) {
    mySerial.write("AT");
    delay(2000);
  }
}

void loop() {
  if (mySerial.available() > 0) {
    Serial.write(mySerial.read());
  }
}

I have also tried different baud rates but still haven't received anything from the module at all.

Best Answer

One problem I can see in your code is the following line:

while (mySerial.available() < 0) {

The available() method returns the number of characters available and will never be negative, so that means your AT command will never be transmitted, in fact your main code probably isn't starting up. Also you're not terminating the command with a carriage return so try the following code:

while (mySerial.available() == 0) {
  mySerial.println("AT");
  delay(2000);
}

Often when playing around with a new GSM module I find it more convenient to be able to type things from a PC to check operation, so maybe for a start you could use something like this to pass data through:

void loop() {
  if (mySerial.available() > 0)
    Serial.write(mySerial.read());
  if (Serial.available() > 0)
    mySerial.write(Serial.read());
}

I used a very similar board recently with a SIM900 loaded that didn't come with much in the way of documentation and while searching I found some Arduino boards are set for auto-baud and some are fixed at 19200, so using a baud rate of 19200 that should work either way might be your best starting point.