Pages: [1]   Go Down
Author Topic: SM5100B Cellular Shield Troubleshooting  (Read 1299 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been using this cellular shield:
https://www.sparkfun.com/products/9607

And so far, mostly so good. However, I have been having one large problem that has been driving me crazy. Thus far I have had no luck trying to solve it.

Basically, when I call the module from my cell phone, the phone module rings about two times and then crashes. Of course, to complicate matters, this problem only happens about 75% of the time. Sometimes it works perfectly fine, which continues to baffle me further.

When it crashes, the phone module both stops audibly ringing through a speaker I attached and printing the "ring!" alert to the serial terminal. And then, the terminal freezes and the whole thing needs to be rebooted.

To confuse matters even further, it happens with two different sets of code. One is the example code from Sparkfun which echos the feedback from the module back through the serial terminal. The other buffers the incoming serial data and prints out responses based on the incoming data.

This is the sparkfun example code:

Code:
/*
SparkFun Cellular Shield - Pass-Through Sample Sketch
SparkFun Electronics
Written by Ryan Owens
3/8/10

Description: This sketch is written to interface an Arduino Duemillanove to a  Cellular Shield from SparkFun Electronics.
The cellular shield can be purchased here: http://www.sparkfun.com/commerce/product_info.php?products_id=9607
In this sketch serial commands are passed from a terminal program to the SM5100B cellular module; and responses from the cellular
module are posted in the terminal. More information is found in the sketch comments.

An activated SIM card must be inserted into the SIM card holder on the board in order to use the device!

This sketch utilizes the NewSoftSerial library written by Mikal Hart of Arduiniana. The library can be downloaded at this URL:
http://arduiniana.org/libraries/NewSoftSerial/

This code is provided under the Creative Commons Attribution License. More information can be found here:
http://creativecommons.org/licenses/by/3.0/

(Use our code freely! Please just remember to give us credit where it's due. Thanks!)
*/

#include <SoftwareSerial.h>  //Include the NewSoftSerial library to send serial commands to the cellular module.
#include <string.h>         //Used for string manipulations

char incoming_char=0;      //Will hold the incoming character from the Serial Port.

SoftwareSerial cell(2,3);  //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.

void setup()
{
  //Initialize serial ports for communication.
  Serial.begin(9600);
  cell.begin(9600);
 
  //Let's get started!
  Serial.println("Starting SM5100B Communication...");
}

void loop() {
  //If a character comes in from the cellular module...
  if(cell.available() >0)
  {
    incoming_char=cell.read();    //Get the character from the cellular serial port.
    Serial.print(incoming_char);  //Print the incoming character to the terminal.
  }
  //If a character is coming from the terminal to the Arduino...
if( Serial.available( ) > 0)
{
incoming_char = Serial.read( ); // Get the character coming from the terminal
if(incoming_char == '~') // If it’s a tilde…

incoming_char = 0x0D;      // ...convert to a carriage return 

else if( incoming_char == '^') // If it’s an up caret…

incoming_char =  0x1A;    // ...convert to ctrl-Z 

cell.print( incoming_char ); // Send the character to the cellular module.
Serial.print( incoming_char ); // Echo it back to the terminal
}

}

This is the buffering code:

Code:
#include <SoftwareSerial.h>
#include <PString.h>


#define BUFFSIZ 90

char at_buffer[BUFFSIZ];
char buffidx;

int network_registered;
int network_AT_ready;

int firstTimeInLoop = 1;

//int ring = 0;
 
//Will hold the incoming character from the Serial Port.

char incoming_char=0;
char buffer[60];

PString myString(buffer,sizeof(buffer));

//Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.

SoftwareSerial cell(2,3); 



// Do system wide initialization here in this function

void setup() {

  //Initialize serial ports for communication.

  Serial.begin(9600);
  cell.begin(9600);

  //Let's get started!
  Serial.println("Starting SM5100B Communication...");
  delay(1000);

  /* Currently network is not registered and AT is not ready */
 
  network_registered = 0;
  network_AT_ready = 0;

}

 

/* Reads AT String from the SM5100B GSM/network Module */

void readATString(void) {

  char c;
  buffidx= 0; // start at begninning
  while (1) {
    if(cell.available() > 0) {
      c=cell.read();
      if (c == -1) {
        at_buffer[buffidx] = '\0';
        return;
      }
      if (c == '\n') {
        continue;
      }
      if ((buffidx == BUFFSIZ - 1) || (c == '\r')){
        at_buffer[buffidx] = '\0';
        return;
      }
      at_buffer[buffidx++]= c;
    }
  }
}

/* Processes the AT String to determine if network is registered and AT is ready */

void ProcessATString() {

  if( strstr(at_buffer, "+SIND: 8") != 0 ) {
    network_registered = 0;
    Serial.println("network Network Not Available");
  }

  if( strstr(at_buffer, "+SIND: 11") != 0 ) {
    network_registered=1;
    Serial.println("network Registered");
  }
 
  if( strstr(at_buffer, "+SIND: 4") != 0 ) {
    network_AT_ready=1;
    Serial.println("network AT Ready");
  }
}

 
void IncomingCall() {

  if( strstr(at_buffer, "RING") != 0 ) {
    Serial.println("ring!");
  }

  if( strstr(at_buffer, "NO CARRIER") != 0 ) {
    Serial.println("hung up on");
  }
}



void loop() {

/* If called for the first time, loop until network and AT is ready */

if(firstTimeInLoop == 1) {

  firstTimeInLoop = 0;
  while (network_registered == 0 || network_AT_ready == 0) {
    readATString();
    ProcessATString();
    }
  }
  readATString();
  IncomingCall();
}

I'm beginning to suspect that maybe the module is sending junk data back to the Arduino when it gets the ring command. This then confuses and crashes the code... perhaps? However, I have yet to discover any real evidence of this.

I'm at about my wits end on this one. If anyone has any ideas as to what may be going on, it would be appreciated.
Logged

Ontario
Offline Offline
God Member
*****
Karma: 25
Posts: 890
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dumb Q, but how do you have it powered?  Call setup requires the module to run the radio a bit, and a voltage dropout due to heavy current draw could easily cause instability.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Powered off the USB port of my computer. Did not think of that. I guess I'll try something with a little more current.
Logged

Ontario
Offline Offline
God Member
*****
Karma: 25
Posts: 890
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That'll be the problem.  Have a read here: https://tronixstuff.wordpress.com/tag/sm5100b/

Quote
The GSM shield can often require up to 2A of current in short bursts – especially when turned on, reset, or initiating a call.

I have successfully sent and received SMS messages when powered only via USB, but I mainly try to power the Arduino with a large 7.5V AC supply when I am messing with the SM5100.  The page I referenced calls for an external 5V regulator to spare the Arduino one.
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1220
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but I mainly try to power the Arduino with a large 7.5V AC supply



AC  supply  ?,  sure theres a diode, but a half wave rectified supply with only 100 MFd smoothing caps will have a lot of ripple at higher currents.
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Ontario
Offline Offline
God Member
*****
Karma: 25
Posts: 890
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

AC  supply  ?

I mean one that plugs into an AC outlet.  It generates nice clean 7.5 VDC.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay... Gave the shield some more power (regulated 5V / 2A). Still the same error. Back to the drawing board.

I am pretty sure it has something to do with the module returning some sort of strange value when it receives a "ring" message from the telecom company. Everything else seems to work fine (more power or not).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Problem sort of solved. It is the Serial Monitor and/or monitoring the serial port in the terminal. I don't know why exactly this is causing the problem, but I have a few hunches.

It might still be in the code, but I will figure out whats up later. At least I have concluded it is not in the module hardware.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have the same SM5100B shield + software using SoftwareSerial class.
I noticed when module receives a SMS, it stops working in case the ambient temperature drops under 2 Celsius.
At the normal temperature (23 Celsius) it works OK.
I think the problem is the power supply (it is under-dimensionated). I read somewhere that SM5100B takes 3A at full peaks.
In my opinion the power supply must be above 2 Amp. Try one with 2.5A or 3A.
Logged

Pages: [1]   Go Up
Jump to: