Pages: [1]   Go Down
Author Topic: Send information to M5100B-D  (Read 512 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi All,
I not very familiar with the language and am having difficulty setting up my sketch so that the arduino will automatically send commands to the GSM shield without my manual input into two way serial port. I have been able to get the two way communication working to test using the following sketch:
Code:
#include <SoftwareSerial.h>
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);
 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
 cell.print(incoming_char); //Send the character to the cellular module.
 }
}
What I would like to do is automate the input of the command "AT=CCED=0,2" retrieve the information and text the retrieved information to another location.

Any help would be greatly appreciated.

Regards,
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What I would like to do is automate the input of the command "AT=CCED=0,2"
Code:
char *atCmd = "AT=CCED=0,2";

You have to then send that command.

Quote
retrieve the information
What information, from where?

Quote
and text the retrieved information to another location.
Do you know what AT command(s) are needed to do this?
Logged

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

Quote
retrieve the information
When the command AT+CCED=0,2 is sent, a string of information is returned that gives information about Cellid, signal strength etc.
 
Code:
#include <SerialGSM.h>
#include
SerialGSM cell(2,3);
void setup()
{
 delay(30000); // wait for GSM module
 cell.begin(9600);
}
void sendSMS()
{
 cell.Verbose(true); // used for debugging
 cell.Boot();
 cell.FwdSMS2Serial();
 cell.Rcpt("+xxxxxxxxx"); // replace xxxxxxxxx with the recipient's cellular number
 cell.Message("Contents of your text message");
 cell.SendSMS();
}
void loop()
{
 sendSMS();
 do // remove this loop at your peril
 {
 delay(1);
 }
 while (1>0);
}
The tutorial I am using for reference with this uses the above code to send an SMS.
The tutorial can be found here: http://tronixstuff.wordpress.com/2011/01/19/tutorial-arduino-and-gsm-cellular-part-one/
Logged

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

I have managed to piece this sketch together
Code:
#include <SoftwareSerial.h>
char incoming_char=0; //Will hold the incoming character from the Serial Port.
SoftwareSerial cell(2,3);
void setup()
{
  Serial.begin(9600);
  cell.begin(9600);
 Serial.println("Starting SM5100B Communication...");
 delay(35000); // give the GSM module time to initialise, locate network etc.
 // this delay time varies. Use example 26.1 sketch to measure the amount
 // of time from board reset to SIND: 4, then add five seconds just in case
}
void loop()
{
  cell.println("AT+CCED=0,2");
   //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
 cell.print(incoming_char); //Send the character to the cellular module.
 }
 delay(20000); // wait 20 seconds.
}
I believe this should work (not really) when I upload this and run the serial port the text prints into the serial port letter by letter with 20sec delay. What I need is for this part of the code
Quote
   //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
 cell.print(incoming_char); //Send the character to the cellular module.
 }
 delay(20000); // wait 20 seconds.
}


to be constantly looping while the other part at a much slower rate.

A loop in a loop? is this possible?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I believe this should work (not really) when I upload this and run the serial port the text prints into the serial port letter by letter with 20sec delay.
Why? What that does is cause the AT command to be executed every 20 seconds, and only one character is read per execution.

Quote
to be constantly looping while the other part at a much slower rate.
"To be constantly looping" doesn't make a lot of sense. Try again.

You should absolutely get rid of that delay(). You should also have a look at the blink without delay example to learn how to do things at regular intervals with needing to use that crutch.
Logged

Pages: [1]   Go Up
Jump to: