Help with GSM Shield


#1

Hello
I am new to Arduino, although I have had 40 years of practice with industrial control systems.
I have a project in my mind that requires an SMS driven control system. I have hit a hurdle that I was hoping someone could help me with.
I have a Leonardo and a SIM900 GSM Shield.
https://littlebirdelectronics.com.au/products/arduino-gsm-gprs-shield

I downloaded the Test Code from the page above, compiled and uploaded. I get the following Message

"Trying to force the baud-rate to 9600

1200
2400
4800
9600
19200
38400
57600
115200
ERROR: SIM900 doesn't answer. Check power and serial pins in GSM.cpp

status=IDLE"

I followed this up a bit and can see that the message is coming from the included librarys GSM.h and GSM.cpp. The way I understand this is that it really is saying that the GSM shield can not connect to the phone network.
The sim card is OK, I have tried with two different sim cards, both work in a phone but give the same error message in the GSM Shield.

Is anyone able to help me work out what is going wrong?

I am sure I have enough power, USB and a 12V car battery. The GSM.cpp assigns pin 8 and 9, this seems to be correct.

thanks
Warren


#2

You’re right, the code in GSP.cpp has failed to communicate and is trying a fall-back method. Here’s what I would do;

  • look at the Net Status LED on the module, and compare it against the table in the datasheet, to find out what the module thinks it is doing,

  • check the TX and RX are around the right way; it would be easy to get them swapped; the schematic is a tad ambiguous; the TXD pin on the module is buffered by a level converter and then labelled RX on the Arduino side, which means it is actually an output,

  • check the soft serial vs UART jumpers are properly in place; and conducting; jumpers have never gone wrong for me, but probing the pins with a multimeter will prove it, (or connect to the Leonardo via the centre pin on the jumpers instead of the edge connector),

  • with the serial pins disconnected from the Leonardo (e.g. by removing the jumpers), measure their voltage; the receive pin should be at 5V due to R16, and the transmit pin at ground or 3.3V,

  • probe the serial pins with oscilloscope (or an LED) to make sure data is being transmitted to the module, and see if there is a reply that the Leonardo isn’t seeing.

Hope that helps!


#3

Thanks James

look at the Net Status LED on the module, and compare it against the table
in the datasheet, to find out what the module thinks it is doing,

Around 10 flashes in 10 secs. So I make that Sim900 not registered (but
trying?). It turns off after a while. I assume this is the software
giving up and switching to idle.

The red light is on while it is connected. The green light goes on and the
blue starts flashing. It goes through two cycles of this then the blue
and green lights switch off.

check the TX and RX are around the right way; it would be easy to get

them swapped; the schematic is a tad ambiguous; the TXD pin on the
module is buffered by a level converter and then labelled RX on the
Arduino side, which means it is actually an output,

I am sorry but I do not really understand this question. I can see that
pins 8, 9 and 10 are the only pins used on the GSM module, but it simply
sits on top. Am I being thick?

check the soft serial vs UART jumpers are properly in place; and
conducting; jumpers have never gone wrong for me, but probing the pins
with a multimeter will prove it, (or connect to the Leonardo via the
centre pin on the jumpers instead of the edge connector),

Jumpers are OK

with the serial pins disconnected from the Leonardo (e.g. by removing the
jumpers), measure their voltage; the receive pin should be at 5V due to
R16, and the transmit pin at ground or 3.3V,

rX PIN 5v, The Tx pin seems to be floating (showing 0.01V)

The SW pin on the RX side is 4.9 V. The SW pin on the TX side is 5 v.

I very much appreciate your help James
Regards
Warren


#4

Oh, sorry! I’d forgotten the shape of the Leonardo. The module just plugs in. I had imagined you wiring it with jumpers from one board to the other. My mistake.

Your voltage readings look good.

According to the schematic, with the jumpers in soft serial position, Leonardo pin D2 should be used for transmit, and pin D3 should be used for receive. I’ve checked, and GSM.cpp seems to have those properly defined. But GSM.cpp also says there is a different version of the shield that uses different Leonardo pins; D4 and D5. That will cause what you observed. So can you trace the circuit from the SW side of the jumpers JP1 and JP2 to find which pins they go to on the Leonardo?

You mention pins 8, 9 and 10. I’m confused about that. The schematic says D8 and D9 are PERKEY and NRESET respectively. But nothing for D10. Perhaps you mean how the SIM900 module pins 9 and 10 are used for TXD and RXD respectively. Yeah, that seems likely. :grin:

Which test sketch are you using? Can you paste it here? Put three backticks (`) above and below it to quote it.

like so

The product link you gave has stopped working for me, which is puzzling.


#5

James

Sorry for the confusion, I had a proper look and you are correct Tx -SW is connected to Leonardo pin2, Rx - SW is connected to Leonardo pin 3. Pins 8 and 9 are resets as you said.
Also Little Bird Electronics has removed the link to the page for the Shield, It now returns a 404 error. Puzzling and perplexing.
It does seem to be the same Specs and .zip file available from TinySine
Sorry I am only allowed to put two links. If you search for TinySine and Sim900 you will find it.

I started with the sketch GSM_GPRSLibrary_SMS.ino

#include "SIM900.h"
#include <SoftwareSerial.h>
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"

//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;

//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 send and receive SMS.

int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];

//debug begin
char sms_position;
char phone_number[20]; // array for the phone number string
char sms_text[100];
int i;
//debug end


void setup()
{
    //Serial connection.
    Serial.begin(9600);
    //Added from Tip johnwasser to work around Leonardo setup not showing Serial.printin;
   // while the serial stream is not open, do nothing:
   while (!Serial) ;
    Serial.println("GSM Shield testing.");

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

    if(started) 
    {
        //Enable this two lines if you want to send an SMS.
        //if (sms.SendSMS("xxxxmyNumberHerexxx", "Arduino SMS"))
        //Serial.println("\nSMS sent OK");
       
       //if NO SPACE ,you need delte SMS  from position 1 to position 20
       //please enable this four lines
       //for(i=1;i<=20;i++)
       //{
           //sms.DeleteSMS(i);
       //}
    }
    
};

void loop()
{
    if(started) 
    {
        //Read if there are messages on SIM card and print them.
        sms_position=sms.IsSMSPresent(SMS_UNREAD);
        if (sms_position) 
        {
            // read new SMS
            Serial.print("SMS postion:");
            Serial.println(sms_position,DEC);
            sms.GetSMS(sms_position, phone_number, sms_text, 100);
            // now we have phone number string in phone_num
            Serial.println(phone_number);
            // and SMS text in sms_text
            Serial.println(sms_text);
        }   
        else
        {
            Serial.println("NO NEW SMS,WAITTING");
        }     
        delay(1000);
    }
};

I also tried a sketch from http://educ8s.tv/arduino-gsm-shield/

  //////////////////////////////////////////////
  //        Arduino GSM SHIELD SMS            //
 //              Tutorial by                 //
//           http://www.educ8s.tv           //
/////////////////////////////////////////////


#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
SMSGSM sms;

int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];

char sms_position;
char phone_number[20];
char sms_text[100];
int i;

void setup()
{
    Serial.begin(9600);
    
    if (gsm.begin(9600)) 
    {
        Serial.println("\nstatus=READY");
        started=true;
    } 
    else 
        Serial.println("\nstatus=IDLE");

    if(started) 
    {
        if (sms.SendSMS("+xxxMyNumberHerexxxxx", "Arduino SMS"))
        {
          Serial.println("\nSMS sent OK.");
        }
        else
        {
          Serial.println("\nError sending SMS.");
        }      
    }
};

void loop()
{
    if(started) 
    {
        sms_position=sms.IsSMSPresent(SMS_UNREAD);
        if (sms_position) 
        {
            Serial.print("SMS postion:");
            Serial.println(sms_position,DEC);
            sms.GetSMS(sms_position, phone_number, sms_text, 100);
            Serial.println(phone_number);
            Serial.println(sms_text);
        }      
        delay(2000);
    }
};

The sketch is different but it uses the same library files, . Perhaps I should not be surprised that it comes up with the same behavior and errors.

I remain confused.
Warren


#6

Thanks, we’re making good progress.

The next step is to make sure electrically that the Leonardo is sending serial data to the module, and to see if serial data is coming back from the module. If data is being sent but nothing is coming back, and there is no other explanation, then I’d return the module. If no data is being sent by the Leonardo, and there is no explanation, then I’d return the Leonardo.

Do you have an oscilloscope? If so, probe D2 and D3. Watch the trace when the sketch starts. If not, attach D2 and D3 through 470 ohm resistors and an LED; each. I’d use a breadboard and jumpers. Watch the LEDs for the pattern of flicker when the sketch starts.

Do you have any other Arduino or serial adapter boards? Another method is to conjoin the RX pin of another board so there are two receivers of data. An extra listener. It’s a complex method and I’m loath to get into it unless necessary. :grin:

p.s. you didn’t use three backticks (`) but instead another tick (’) and so the sketch formatting was dodgy here. Give three backticks a try to see how it works in the discourse forum preview. You could also go back and edit your previous post if you like. I can’t edit it.


#7

Thanks again.
I will get back to you in a couple of days, life interrupts.

BTW I fixed the formatting, thanks for that tip as well.

I have another general question that you may know the answer to. If there are two library files with the same name in different sub-directories, what happens with the include function? In this case there are two GSM library files one in the sub-directory I mad and one in the preloaded GSM library. In my case I temporarily removed the pre-existing library so for me I am sure it is not a problem, but can this situation cause a problem.
Thanks again


#8

Interesting question. I found it hard to be brief, sorry.

In theory the new library will override the existing library; because the libraries directory next to, or inside your sketch directory will be searched before the libraries directory that belongs to the Arduino IDE.

You can test by adding a mistake to one of the .h files to see if it is used. Build will fail and you can then fix the mistake.

On the one hand this is a very useful feature because it lets you customise a library without having to reinstall the Arduino IDE.

On the other hand, it means you may have different versions of a library scattered across your system, and this can lead to coding mistakes. Cause of mistakes is forgetting which of the different libraries you are coding against. In industry we would normally enforce version control for every dependency to avoid this. Not smug, just professional approach.

I find it easier to stick to one version of every library, but the way the Arduino IDE is packaged with libraries preloaded makes this a bit of a challenge.

Most people would use the Library Manager now, along with Sketch -> Import Library instead of unpacking files. It is a recent feature of Arduino IDE. With a lot of old instructions on the 'net for installing libraries, people will still try unpacking themselves.

Some people install the Arduino IDE from GitHub source and maintain each library separately.

Few people use different build-chain integration; such as Ino, and that’s my preference for anything more than a quick hack, because it fits with my use of git, emacs, python, and shell scripting. Lot of work that needs to have a good reason; which for me is leveraging my other tool-based skills.

Also possible to get closer to the metal, using a compiler directly. I’ve tried this and it works great, very efficient, but integrating contributed libraries takes a little bit longer.


#9

Thanks for the explanation. I can see the advantages of having several copies of the library during development, but it rapidly become a pain once the project was developed. I will try to be a bit more disciplined.

Back to my problem. I now have another Leonardo, I tried the setup with the second board and no change.

I also borrowed a serial board and listened to Pin 2 and 3.
Pin2

[06][06]f怘€[06][06]f怘€[06][06]f怘€[06][06]f怘€[06][06]f怘€
NORMAL POWER DOWN
[02]ø
RDY

+CFUN: 1

+CPIN: READY

Call Ready
[06][06]f怘€[06][06]f怘€[06][06]f怘€[06][06]f怘€[06][06]f怘€
NORMAL POWER DOWN
[02]ø
RDY

+CFUN: 1

+CPIN: READY

Call Ready

Pin3
```[06]03怘€[06]03怘€[06]03怘€[06]0fóÀ˜€[06]03怘€[06]03怘€[06]03怘€[06]°3怘€[06]03怘€[06]03怘€[06]03怘€[06]˜3怘€[06]03怘€[06]03怘€[06]0fóÀ˜€[06]03怘€[06]03怘€[06]03怘€[06]03怘€[06]03怘€[06]03怘€[06]03怘€[06]03怘€[06]03怘€[06]03怘€€[00]€[00]€€€€€€[00]€[00][00]€[00]€€[00][00]€€€€[00]€[00][00][00]€[00][00][00][00][00]€€[00]AT AT AT AT AT x[00]x[00]‡x<ÿx[1E]ð<à€x[00]x<ð€x<[0F]€xà€€ø€[00]€[00]€xü[00]AT AT AT AT AT [06]03ž††˜[00]™[18]3æ˜ø[18]Ï[18]À[18]À˜[1E]ðAT
AT
AT
AT
AT
AT+IPR=9600
AT
AT
AT
AT
AT
[00]G Æ…DAT
AT
AT
AT
AT
{ÃÿAT
AT
AT
AT
AT
dðAT
AT
AT
AT
AT
AT
AT
AT
AT
AT

Clearly the Leonardo is talking to and from the GSM Shield but the conversation does not seem to go any further.
Does this mean the GSM Shield has a problem, or is there something with my setup that is different from the examples on the net that use this shield.
Thanks

#10

I agree, the module looks like it can respond. My guess is that the library and the module firmware are incompatible. You might need a different library, or you might have to fix the library to be compatible. Try talking to the module interactively with a serial terminal emulator using the module command documentation. By typing at it with a keyboard, experimentally, you may rapidly learn what the problem might be.


#11

OK I am fairly sure I have found the solution, but it is a little embarrassing. I will outline the issues here to save someone else the embarrassment.
I ran the GSM Shield with an Arduino Uno rather than the Leonardo. It behaved better, proceeding through the setup and moving to the loop. However it still did not connect to the phone network. Then I remembered that Telstra has closed the G2 network. I have access to an Optus SIM card, they are not closing this network for another year. The shield and sketch did everything it was supposed to with the Uno and an Optus SIM.

OK I understand the “buyer beware” concept, but I do think that Little Bird Electronics is being not entirely moral by not pointing out more clearly that the shield I purchased recently will not work on the Telstra network, and will soon not work anywhere in Australia. This also explains why Little Bird has removed the Shield from its website, too late for me though.

The problem with the Leonardo is separate, it seems that the sketch, well the library, has some command / commands that need to be modified. I see little point in pursuing a solution for a shield that is obsolete.
Thanks for your help.


#12

Thanks for the update. Yes, avoid networks that are about to close. I hit that with CDMA. 3G still has a while to go before we all have to buy new devices again. Only one product seems to fit that; ITEAD 3G Shield.

Longer term there are also commercial LoRa networks opening up, on their own frequency allocations, which will undercut the 3G and 4G networks in the machine to machine market, but with their own set of compatible devices. I’d love to see that kind of gear at LBE.