Go Down

Topic: SIM900 Quad-band GSM/GPRS Shield and Arduino Uno (Read 5550 times) previous topic - next topic

oscar2015

A few days ago I received the SIM900 Quad-band GSM/GPRS Shield for Arduino. I want to send data from a temperature sensor to a MySQL data base but I can not comunicate the arduino uno with the shield.
I tested the shield following the steps from this link http://www.simpasture.com/36023.html but when I type the letters AT in the serial monitor, I receive nothing.

what is wrong?

thanks in advance.

dannable

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

oscar2015

the shield is this: http://www.ebay.com/itm/SIM900-Quad-band-GSM-GPRS-Shield-for-Arduino-/221176159800

dannable

Yes, I know that one, the TinyOS one. You have changed the pins that SoftwareSerial uses haven't you?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

oscar2015

no I havenĀ“t.
what Softwareserial pins uses this shield?

dannable

Set the jumpers to SW, and use

Code: [Select]
SoftwareSerial GPRS(2, 3);

D8 is the software power pin.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

oscar2015

I set the pins but I still receive nothing in the serial monitor.

this is the code:
Code: [Select]
//Serial Relay - Arduino will patch a
//serial link between the computer and the GPRS Shield
//at 19200 bps 8-N-1
//Computer is connected to Hardware UART
//GPRS Shield is connected to the Software UART

#include <SoftwareSerial.h>

SoftwareSerial GPRS(2, 3);

unsigned char buffer[64];  // buffer array for data receive over serial port
int count=0;               // counter for buffer array

void setup()
{
  GPRS.begin(19200);
  Serial.begin(19200);
}

void loop()
{
  if (GPRS.available())
  {
    while(GPRS.available())
    {
      buffer[count++]=GPRS.read();
      if(count == 64)break;
    }
    Serial.write(buffer,count);
    clearBufferArray();
    count = 0;
  }
  if (Serial.available())
    GPRS.write(Serial.read());
}

void clearBufferArray()
{
  for (int i=0; i<count;i++)
  {
    buffer[i]=NULL;
  }
}

oscar2015

Now, I type "AT" in the serial monitor and I receive "AT" but "OK" doesnt appear.

dannable

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

dannable

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

oscar2015

hi again.

I tried all what you said but nothing happens and then I tried this code and it works.
Code: [Select]
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "inetGSM.h"
//#include "sms.h"
//#include "call.h"

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to start a connection as client.

InetGSM inet;
//CallGSM call;
//SMSGSM sms;

char msg[50];
int numdata;
char inSerial[50];
int i=0;
boolean started=false;

void setup()
{
     //Serial connection.
     Serial.begin(9600);
     Serial.println("GSM Shield testing.");
     //Start configuration of shield with baudrate.
     //For http uses is raccomanded to use 4800 or slower.
     if (gsm.begin(2400)) {
          Serial.println("\nstatus=READY");
          started=true;
     } else Serial.println("\nstatus=IDLE");

     if(started) {
          //GPRS attach, put in order APN, username and password.
          //If no needed auth let them blank.
          if (inet.attachGPRS("internet.wind", "", ""))
               Serial.println("status=ATTACHED");
          else Serial.println("status=ERROR");
          delay(1000);

          //Read IP address.
          gsm.SimpleWriteln("AT+CIFSR");
          delay(5000);
          //Read until serial buffer is empty.
          gsm.WhileSimpleRead();

          //TCP Client GET, send a GET request to the server and
          //save the reply.
          numdata=inet.httpGET("www.google.com", 80, "/", msg, 50);
          //Print the results.
          Serial.println("\nNumber of data received:");
          Serial.println(numdata);
          Serial.println("\nData received:");
          Serial.println(msg);
     }
};

void loop()
{
     //Read for new byte on serial hardware,
     //and write them on NewSoftSerial.
     serialhwread();
     //Read for new byte on NewSoftSerial.
     serialswread();
};

void serialhwread()
{
     i=0;
     if (Serial.available() > 0) {
          while (Serial.available() > 0) {
               inSerial[i]=(Serial.read());
               delay(10);
               i++;
          }

          inSerial[i]='\0';
          if(!strcmp(inSerial,"/END")) {
               Serial.println("_");
               inSerial[0]=0x1a;
               inSerial[1]='\0';
               gsm.SimpleWriteln(inSerial);
          }
          //Send a saved AT command using serial port.
          if(!strcmp(inSerial,"TEST")) {
               Serial.println("SIGNAL QUALITY");
               gsm.SimpleWriteln("AT+CSQ");
          }
          //Read last message saved.
          if(!strcmp(inSerial,"MSG")) {
               Serial.println(msg);
          } else {
               Serial.println(inSerial);
               gsm.SimpleWriteln(inSerial);
          }
          inSerial[0]='\0';
     }
}

void serialswread()
{
     gsm.SimpleRead();
}


I modified the code to insert temperature data from a sensor to a MySQL data base but when it execute

Code: [Select]
inet.httpGET("hostname", 80, "/insert_data.php?Temperature=22.4&Ph=5.5", msg, 50);

the green led of the shield turns off and doesn't upload the data. I use a USB from de pc to supply power to the arduino.
maybe is not enough power?

dannable

All the GPRS shields I have come across can draw up to 2 amps when transmitting. If the voltage drops below a certain level then the SIM900 will automatically shut down.

I strongly suspect you aren't providing enough power.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

oscar2015

what do you recommend? DC 9V/1A Power Supply? DC 12V/86mA Power Supply? I am afraid to fry up the arduino

dannable

If that's the selection you have available then the 9 volt supply. Personally I use 5 volt, 2 amp supplies.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

oscar2015

Thanks for your help.
I was looking for a 5v 2amp power supply and I found it but the problem continues. I will try the 9v 1amp power supply and then I tell you.

Go Up