Arduino GPRS Shield SIM900 not working by software

ZiTAL
Posts: 2
Joined: Sat Nov 16, 2013 10:55 pm

Arduino GPRS Shield SIM900 not working by software

Post by ZiTAL » Wed Nov 20, 2013 12:37 am

Hi i have an Arduino GPRS Shield SIM900.

The shield works fine with hardware mode (PIN 0,1) but i can't put working with software mode (7/8).

I put the jumpers the right way and doen't works:

Image

Code: Select all

#include <SoftwareSerial.h>
#include <String.h>
SoftwareSerial mySerial(7, 8);
void setup()
{
 mySerial.begin(19200);  // the GPRS baud rate   
 powerUp();
 delay(5000);
 sendSms();
 delay(10000);
}

void powerUp()
{
 pinMode(9, OUTPUT); 
 digitalWrite(9,LOW);
 delay(1000);
 digitalWrite(9,HIGH);
 delay(2000);
 digitalWrite(9,LOW);
 delay(3000);
}

///SendTextMessage()
///this function is to send a sms message
void sendSms()
{
 mySerial.print("\r");
 mySerial.print("AT+CMGF=1\r");
 delay(1000);
 mySerial.print("AT+CMGS=\"+34123456789\"\r");
 delay(1000);
 mySerial.print("Arduino SMS Test by soft! \r");//the content of the message
 delay(1000);
 mySerial.print((char)26);//the ASCII code of the ctrl+z is 26
 mySerial.print("\r");
 //mySerial.write(0x1A);
 delay(1000);
}

void loop()
{
}
i changed the jumpers to hardware mode and this code works:

Code: Select all

void setup()
{
  Serial.begin(19200);  //Baud rate of the GSM/GPRS Module
  powerUp();
  Serial.print("\r");
  delay(1000);
  Serial.print("AT+CMGF=1\r");
  delay(1000);
  Serial.print("AT+CMGS=\"+34123456789\"\r");    //Number to which you want to send the sms
  delay(1000);
  Serial.print("Arduino SMS hard Test! \r");   //The text of the message to be sent
  delay(1000);
  //Serial.write(0x1A);
  Serial.print((char)26);//the ASCII code of the ctrl+z is 26  
  Serial.print("\r");
  delay(1000);
}

void powerUp()
{
 pinMode(9, OUTPUT); 
 digitalWrite(9,LOW);
 delay(1000);
 digitalWrite(9,HIGH);
 delay(2000);
 digitalWrite(9,LOW);
 delay(3000);
}

void loop()
{
}
[code]

The Shield power up with both code.

Watching this wiki:
[url]http://www.geeetech.com/wiki/index.php/Arduino_GPRS_Shield[/url]

i try with this code to work with hyperterminal/minicom:

[code]
//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(7, 8);
unsigned char buffer[64]; // buffer array for data recieve over serial port
int count=0;     // counter for buffer array 
void setup()
{
 GPRS.begin(19200);               // the GPRS baud rate   
 Serial.begin(19200);             // the Serial port of Arduino baud rate.
}
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
}
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
}
but compiling arduino says:

Code: Select all

sketch_nov19a.ino: In function ‘void loop()’:
sketch_nov19a:17: error: ‘class SoftwareSerial’ has no member named ‘available’
sketch_nov19a:19: error: ‘class SoftwareSerial’ has no member named ‘available’
sketch_nov19a:29: error: ‘class SoftwareSerial’ has no member named ‘write’
Here is the SoftwareSerial code:
SoftwareSerial: https://github.com/ZiTAL/arduino/tree/m ... wareSerial

User avatar
jack
Posts: 77
Joined: Sat Mar 03, 2012 2:25 pm

Re: Arduino GPRS Shield SIM900 not working by software

Post by jack » Thu Nov 21, 2013 11:54 am

the port 7 8 can not worked at software mode.

ZiTAL
Posts: 2
Joined: Sat Nov 16, 2013 10:55 pm

Re: Arduino GPRS Shield SIM900 not working by software

Post by ZiTAL » Thu Nov 21, 2013 3:36 pm

Software Serial Selected
Use D7 and D8 of the
Arduino to communicate

User avatar
jack
Posts: 77
Joined: Sat Mar 03, 2012 2:25 pm

Re: Arduino GPRS Shield SIM900 not working by software

Post by jack » Fri Nov 22, 2013 3:58 pm

you shuld weld it like this
Attachments
1000.png
1000.png (590.86 KiB) Viewed 51504 times

jafarin
Posts: 6
Joined: Tue Jul 22, 2014 7:34 pm

Re: Arduino GPRS Shield SIM900 not working by software

Post by jafarin » Tue Jul 22, 2014 7:48 pm

Old post, but I found it worth of nothing and I want to open questions why JP need to weld? That JP is used only for get D9 to working to start and shutdown GPRS Shield by arduino
Software Triger; If use this way to power up the GPRS Shield, JP need to be soldered, then Digital Pin 9 of the Arduino will act as Software Triger port and Digital Pin 9 can not be use as other purpose.
I have just same problem as Zital have. What wrong is with software mode in arduino or GPRS Shield v1.0?

Regards
Jafarin

User avatar
techsupport
Site Admin
Posts: 210
Joined: Sat Mar 03, 2012 2:32 pm

Re: Arduino GPRS Shield SIM900 not working by software

Post by techsupport » Wed Jul 23, 2014 4:11 pm

Hi jafarin
Are the baud rate of GPRS communication and simulation of serial port communication rate consistent?
Your real trustworthy partner in China!!
Email: forum@geeetech.com

jafarin
Posts: 6
Joined: Tue Jul 22, 2014 7:34 pm

Re: Arduino GPRS Shield SIM900 not working by software

Post by jafarin » Tue Jul 29, 2014 11:28 pm

It seems that baud rate of GSM shield v1 changing by it self or GSM shield cant keep it right. Next thread I told that I hunted baud rate to get OK from shield. Next time rate wasn't always same.

http://www.geeetech.com/forum/viewtopic ... 549#p20549

I must say that I am confused. Why GSM shield baud rate change by it self? If I dont get it work soon, I must make request to seller to get new shield or money.

jafarin
Posts: 6
Joined: Tue Jul 22, 2014 7:34 pm

Re: Arduino GPRS Shield SIM900 not working by software

Post by jafarin » Wed Jul 30, 2014 6:07 am

I understand what you mean. Now I have hunted problem and software port D7/8 are between arduino and GSM shield. Serial port D0/1 are only used for debug.

With this code I found that some reason I have GSM shield where baud rate dont stay in same speed.

Code: Select all

#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
unsigned char buffer[64]; // buffer array for data recieve over serial port
int count=0;     // counter for buffer array 
int workingSpeed=0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
   Serial.println("Testing GSM shield...");
   int speed[] = {2400,4800,9600,14400,19200,115200};
   if (workingSpeed==0) for (int i = 0; i < 5;i++) 
   {
      startGSMtest(speed[i]);
      
   }
   while(true){};
}


void startGSMtest(int baud){
   SIM900.begin(baud);
   Serial.print(" start GSM speed ");
   Serial.print(baud);
   Serial.println(" baud");
   SIM900.println("AT");
   delay(1000);
   if (SIM900.available()) {
      while(SIM900.available())          // reading data into char array 
       {
            buffer[count++]=SIM900.read();     // writing data into array
            if(count == 64)break;
        }
        if (buffer[0]='O'){
           workingSpeed=baud;
        }
       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
   }
}

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
}

Lemon
Posts: 40
Joined: Thu Jul 03, 2014 9:13 am

Re: Arduino GPRS Shield SIM900 not working by software

Post by Lemon » Fri Aug 01, 2014 9:04 am

jafarin wrote:I understand what you mean. Now I have hunted problem and software port D7/8 are between arduino and GSM shield. Serial port D0/1 are only used for debug.

With this code I found that some reason I have GSM shield where baud rate dont stay in same speed.

Code: Select all

#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
unsigned char buffer[64]; // buffer array for data recieve over serial port
int count=0;     // counter for buffer array 
int workingSpeed=0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
   Serial.println("Testing GSM shield...");
   int speed[] = {2400,4800,9600,14400,19200,115200};
   if (workingSpeed==0) for (int i = 0; i < 5;i++) 
   {
      startGSMtest(speed[i]);
      
   }
   while(true){};
}


void startGSMtest(int baud){
   SIM900.begin(baud);
   Serial.print(" start GSM speed ");
   Serial.print(baud);
   Serial.println(" baud");
   SIM900.println("AT");
   delay(1000);
   if (SIM900.available()) {
      while(SIM900.available())          // reading data into char array 
       {
            buffer[count++]=SIM900.read();     // writing data into array
            if(count == 64)break;
        }
        if (buffer[0]='O'){
           workingSpeed=baud;
        }
       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
   }
}

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
}

Dear friend,
According to your question, could you please be patient and try to test the items according to the following steps:
1. Confirm the baud rate.
2. Do you install the function library successfully?
3. When you use io port to simulate, is it appear some error message?
Waiting your reply. Best regards.

jafarin
Posts: 6
Joined: Tue Jul 22, 2014 7:34 pm

Re: Arduino GPRS Shield SIM900 not working by software

Post by jafarin » Mon Aug 11, 2014 1:41 am

I found my problem. GSM Shield wasn't used fixed baud rate. It was set to use auto-baud rate and that's why it wasn't answer as I expected. Baud speed syncronate wasn't get up and I too fast expected that my shield was broken.

Code: Select all

AT+IPR=?

+IPR: (),(0,1200,2400,4800,9600,19200,38400,57600,115200)

OK

at

OK
AT+IPR?

+IPR: 0

OK
As you see shield baud rate is 0, what means autobaud. Thats why it is important to send AT-command, until shield give OK response. Then speed is sync and access is rdy. Also when auto-baud is used, some responses are missing. When I change baud speed to fixed, I start to get more responses, when I start shield.

Code: Select all

AT+ipr=19200

OK
AT+ipr?

+IPR: 19200

OK

NORMAL POWER DOWN
ÿÿÿÿÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
Now my shield is rdy for rumble. :)

Post Reply