Arduino Forum

Products => Arduino GSM Shield => Topic started by: Far27 on Aug 13, 2017, 05:37 pm

Title: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: Far27 on Aug 13, 2017, 05:37 pm
Hello everyone,
I am a newbie trying to get my hands on working with Arduino Uno R3 and Arduino GPRS/GSM SIM900 Shield. I have connected the two devices based on the recommendations I got from results from google search. I have also implemented some of the steps I saw on this forum but none has worked form me. I have not worked with electronics before.
The devices are using are Arduino Uno R3 (http://hub360.com.ng/shop-2/arduino-uno-r3/) and Arduino GPRS/GSM Shield (http://hub360.com.ng/shop-2/simcom-sim900-shield/).
Including SIM card and jumper wires
1. I am using a Windows 10 OS on a HP laptop.
2. I configured my Arduino Uno R3 COM port to use 19200 baud rate from Device Manager.
3. I also made sure my Arduino Uno R3 IDE is  using the same COM port.
4. I have connected my devices and  I have also included the images of my connection as attachment.
5. I am using a 9v 2a power adapter to power the SIM900 and usb for Arduino Uno R3.

Please I will like to know if my connection is correct?

I tried send a message using a piece of code I copied from a pdf I got while search for materials and I have the code here

Code: [Select]
#include <SoftwareSerial.h>

SoftwareSerial GPRS(7, 8);         //7 = TX, 8 = RX
unsigned char buffer[64];
int port = 11;
int count=0;     
int i = 1;                         //if i = 0, send SMS.
void setup(){
  //delay(10000);
  GPRS.begin(19200);               // the GPRS baud rate   
  Serial.begin(19200);             // the Serial port of Arduino baud rate.
  Serial.print("I'm ready");
  Serial.print("Hello?");
}

void loop(){
  if (GPRS.available()){         // if date is comming from softwareserial port ==> data is comming from gprs shield

    while(GPRS.available()){          // reading data into char array
      buffer[count++]=GPRS.read();     // writing data into array
      if(count == 64)break;
    }
  Serial.write(buffer,count);            // if no data transmission ends, write buffer to hardware serial port
  clearBufferArray();              // call clearBufferArray function to clear the storaged data from the array
  count = 0;                       // set counter of while loop to zero
}

if (Serial.available())            // if data is available on hardwareserial port ==> data is comming from PC or notebook
  GPRS.write(Serial.read());       // write it to the GPRS shield
  if(i == 0){
    GPRS.print("AT+CMGF=1\r"); //sending SMS in text mode
    Serial.println("AT+CMGF=1\r");
    delay(1000);
    GPRS.print("AT+CMGS=\"+2347xxxxxxxx\"\r"); // phone number
    Serial.println("AT+CMGS=\"+2347xxxxxxxx\"\r");
    delay(1000);
    GPRS.print("Test\r"); // message
    Serial.println("Test\r");
    delay(1000);
    GPRS.write(0x1A); //send a Ctrl+Z(end of the message)
    delay(1000);
    Serial.println("SMS sent successfully");
    i++;
  }   
}

void clearBufferArray(){              // function to clear buffer array
  for (int i=0; i<count;i++){
    buffer[i]=NULL;                  // clear all index of array with command NULL
  }
}



When I upload the sketch the my Arduino Uno R3 I get
I'm readyHello?

I have attached my connection for inspection.
Please I need help with this problem.
Thanks.
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: dannable on Aug 13, 2017, 09:34 pm
I can't see much in your photo, to small, washed out and out of focus I'm afraid.

Take a look at the link in my signature which covers connecting a similar shield.
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: Far27 on Aug 14, 2017, 12:52 pm
Thanks dannable for your swift response. I have seen that page before and I have read through it again I tried the serial test communication on that page, but I didn't an Ok. This is the link to the connection I am using.

https://arduino.stackexchange.com/questions/9483/how-to-communicate-the-arduino-board-with-sim900
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: dannable on Aug 14, 2017, 12:56 pm
Even the photo on SE isn't good enough to read the printing on the pcb.
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: Far27 on Aug 20, 2017, 03:31 am
Please this is my connection I will like you to have a look at and advice me.
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: lastchancename on Aug 20, 2017, 11:28 am
Before getting your SMS to run - load up a simple local echo program to send your typing to the modem and vice versa.  That will let you know you have communication tot he modem.

You can check the modem connection status, etc

After that - you can start faffing around with a functional sketch code, but always keep that echo code nearby so you can see what is expected & returning.
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: dannable on Aug 20, 2017, 06:17 pm
I've found a similar board to yours and the first thing I note is where you have your Rx/Tx connections. Try connecting to D7 & D8 on the SIM900 board (assuming that you have the two jumpers near the aerial set to use D7 & D8, and that is how it appears.).
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: Far27 on Aug 20, 2017, 07:57 pm
Before getting your SMS to run - load up a simple local echo program to send your typing to the modem and vice versa.  That will let you know you have communication tot he modem.

You can check the modem connection status, etc

After that - you can start faffing around with a functional sketch code, but always keep that echo code nearby so you can see what is expected & returning.
Thanks for your response. Please I don't know how to load a simple echo program I am pretty new to using Arduino and SIM900 GSM Shield. Is there any example sketch I can use to do that and how can I check modem status please?
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: dannable on Aug 20, 2017, 08:21 pm
Serial Relay sketch

Code: [Select]
// Serial Relay - Arduino will patch a
// serial link between the computer and the GPRS Shield
// at 19200 bps 8-N-1

#define RxPin 7
#define TxPin 8

#include <SoftwareSerial.h>

SoftwareSerial GPRS(RxPin, TxPin); // RX, TX

void setup()
{
  pinMode(13, OUTPUT); // Turn off pin 13
  digitalWrite(13,LOW); 
  GPRS.begin(19200);
  Serial.begin(19200);
}

void loop()
{
  if (GPRS.available())
  {
    while(GPRS.available())
    {
      Serial.write(GPRS.read());
    }
  }
  if (Serial.available())
  {
    while(Serial.available())
    {
      GPRS.write(Serial.read());
    }
  }
}


Open serial monitor and make sure the baud rate is set to 19200. Type AT (return) and it sound echo in the main screen AT OK.
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: Far27 on Aug 20, 2017, 08:25 pm
I've found a similar board to yours and the first thing I note is where you have your Rx/Tx connections. Try connecting to D7 & D8 on the SIM900 board (assuming that you have the two jumpers near the aerial set to use D7 & D8, and that is how it appears.).
Thanks dannable once more. I have tried several connections on the SIM900 board. I have tried using RX2 TX3 on the Arduino Board and RX7 TX8 on the software serial of SIM900.

When I run the GSM_GPRSLibrary_AT example sketch I get DB:NO RESP Trying to force the baud-rate to 9600. ERROR: SIM900 doesn't answer. Check power and serial pins in GSM.cpp status=IDLE.

I am using a USB to power Arduino Uno and a Power adaptor(12.0v 2.0A) for SIM900 GSM Shield.
I have downloaded the SIM900 library and added it to my IDE library.

Please do you have any suggestion
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: dannable on Aug 20, 2017, 08:30 pm
One wire from Uno D7 to SIM900 D7. Another wire Uno D8 to SIM900 D8. Ground to ground. This assumes that the jumper block adjacent to the aerial allows you to select between D0,D1 and D7,D8. I cannot read your board markings.

Load the serial relay sketch as above and try it.

Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: Far27 on Aug 20, 2017, 09:11 pm
I have loaded the serial relay sketch as you instructed using the connection as you have specified but it is still not working. Do you think the SIM900 board is in good condition?
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: dannable on Aug 20, 2017, 09:22 pm
Ridiculous question first - you are turning it on?

What happens when you apply power? Does the net light blink rapidly for several seconds, then change to a slower blink?
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: Far27 on Aug 20, 2017, 10:54 pm
Ridiculous question first - you are turning it on?

What happens when you apply power? Does the net light blink rapidly for several seconds, then change to a slower blink?
Yes it does, but I have been trying to get both device to work for over a month now and it has been so frustrating.
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: dannable on Aug 21, 2017, 03:36 pm
Right, similar module to yours. D7 - D7, D8 - D8, Gnd - Gnd, 9v 1A psu for testing module, USB supply to Uno:

(https://forum.arduino.cc/index.php?action=dlattach;topic=494785.0;attach=223010)

Connect using serial monitor:

(https://forum.arduino.cc/index.php?action=dlattach;topic=494785.0;attach=223012)

I dialed my cell (mobile) phone and it connected.
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: Far27 on Aug 24, 2017, 11:08 am
Thanks dannable for all your support and lucid explanations and illustrations. I have tried to use the  connection based on the image you posted, but it did not work for me. I did not get any response when I typed in AT into my Serial Monitor.

The IDE I am using is ARDUINO 1.8.4 from https://www.arduino.cc/en/Main/Software, and I got word from the shop where I bought the hardware at https://www.hub360.com.ng, here in Nigeria to use ARDUINO 1.6.5, and I uninstalled the 1.8.4 and installed 1.6.5, and when I tried I got an OK from my Serial Monitor.

I have resolved the problem I am having and I say "thank you so much dannable and lastchancename, you guys are a blessing to this forum and because of your speedy response I will like to stick around this community much longer than I thought, I love you guys".

Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: lastchancename on Aug 24, 2017, 11:13 am
Thanks for the 'thanks'...  Dannable did the hard work, i just pushed in one possible direction!
Your learning experience is very standard, so don't despair.
Break every project into its separate parts, otherwise you can rarely find issues hidden by other issues !
Keep us up to date on your progress.
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield sendSMS [SOLVED]
Post by: Far27 on Aug 24, 2017, 11:34 am
You guys are the best. I have edited the title line so other can know that it has been solved. I read through how to use this forum before I attempted making a post.

I am from Nigeria and now I believe in the true power of the open source community. You all are a blessing to our generation.

Thanks
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: dannable on Aug 24, 2017, 12:03 pm
In turn all I did was prove that it should work, meaning that the problem area had been narrowed down. Faulty connections, or in this case version of the IDE, all things that aren't immediately obvious.
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: Far27 on Aug 24, 2017, 03:52 pm
Thanks for making your shoulder available for me to sit on so that I can see further into the Automation Land of Arduino.

In the diagram below, can I use female - female jumper wires to connect the 'SWserial' position on the SIM900 board in place of those connectors you have there? Because I have removed one of them and I cannot find it now. I have two SIM900 shields for now so I am using one of them and will like to use the other when I am through with the project I have in mind.
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: dannable on Aug 24, 2017, 03:58 pm
Yes, there's no problem with doing that, other than additional clutter!
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: Far27 on Aug 24, 2017, 10:21 pm
Please in your years of using SIM900 and other shields have you encountered any IDE related problem? What are the pros and cons of using New Release of an IDE vs Older Versions? Is there anywhere I can get information about IDE compatibility with shields and boards? 
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: dannable on Aug 25, 2017, 08:36 am
I still use an ancient version of the IDE but it works. When it stops working I'll upgrade.

As for your question about differences in the different IDEs, I would ask that further up the board. Try Installation and Troubleshooting, if it's wrong a Moderator will move it.
Title: Re: Problem connecting Arduino Uno R3 to SIM900 GPRS/GSM shield and sending an SMS
Post by: leonhardo on Oct 04, 2017, 01:27 am
Hello
I hope I can help I was working with the SIM900 and the GPS Neo-6M I have already make calls send messages what I need is to transmit data to the web using the GPRS of which I intend to do is to obtain the coordinates with the GPS and by means of the SIM900 send the information obtained to the web.

I leave my code.

#include <TinyGPS.h>
#include <SoftwareSerial.h>

TinyGPS gps;
SoftwareSerial GPS(4, 3);
SoftwareSerial SIM(7, 8);

static void smartdelay(unsigned long ms);
static void print_float(float val, float invalid, int len, int prec);
const int conectar = 2;
const int led = 13;
int conectando = 0;

void setup() {
  Serial.begin(9600);
  SIM.begin(9600);
  GPS.begin(9600);
  pinMode(led, OUTPUT);
  pinMode(conectar, INPUT);
}


void loop() {
  float latitud, longitud;
  gps.f_get_position(&latitud, &longitud);
  Serial.println("Latitud    Longitud  ");
  print_float(latitud, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6);
  print_float(longitud, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6);
 conectando = digitalRead(conectar);
  if (conectando == 0) {
    digitalWrite(led, 0);
    delay(2000);
    SIM.print("AT+CGATT");
    SIM.print("AT+CGDCONT=1,\"IP\",\"internet.itelcel.com\"");// Establece parametros PDP
    SIM.print((char)13);
    delay(2000);
    SIM.print("AT+CSTT=\"internet.itelcel.com\",\"webgprs\",\"webgprs2003\""); //Seteo de APN usuario y password
    SIM.print((char)13);
    delay(2000);
    SIM.print("AT+CIICR");// Inicia la conexión
    SIM.print((char)13);
    delay(20000);
    SIM.print("AT+CIFSR");
    SIM.print((char)13);
    delay(2000);
    SIM.print("AT+CIPSTART=\"TCP\",\"ubicatek.hol\",\"80\"");// Inicia conexion TCP o UDP
    Serial.println("conexion realizada");
    SIM.print((char)13);
    SIM.print((char)10);
    delay(5000);
    SIM.print("AT+CIPSEND");// Envias Datos TCP o UDP
    SIM.print((char)13);
    SIM.print((char)10);
    Serial.println("conexion para enviar");
    delay(2000);
    SIM.print("GET /home.php HTTP/1.1");// //Archivo donde se enviara el dato y el parametro a enviar
    SIM.print("latitud=");
    SIM.print(latitud, TinyGPS::GPS_INVALID_F_ANGLE);
    SIM.print("&longitud=");
    SIM.print(longitud, TinyGPS::GPS_INVALID_F_ANGLE);
    Serial.println("Datos Enviados");
    SIM.print((char)13);
    SIM.print((char)10);
    SIM.print("Host: ubicatek.hol.es");//
    SIM.print((char)13);
    SIM.print((char)10);
    SIM.print((char)10);
    SIM.print((char)13);
    SIM.print((char)10);
    SIM.print((char)26);
    delay(10000);
    SIM.print("AT+CIPCLOSE");// Cierra la conexión TCP o UDP
    SIM.print((char)13);
    delay(2000);
    SIM.print("AT+CIPSHUT"); //Cierra el contesto PDP de GPRS
    SIM.print((char)13);
    delay(2000);
    smartdelay(10000);
  }

  digitalWrite(led, 1);

}

thank your support