GPS/GSM and Arduino UNO

So I am working with a few other people to develop an open source wildlife gps tracker tag for the Florida Wildlife Commission. At its most simple, it needs to take a GPS reading and transmit it to an SMS number. If I can get it to start spitting out serial data in a manner that is readable, I can do the rest easily enough. Object oriented programming is not all that new to me.
However, this shield is utterly baffling me.
I like everyone else is using the wiki located here
http://www.dfrobot.com/wiki/index.php/GPS/GPRS/GSM_Module_V3.0_(SKU:TEL0051)#Trouble_shooting
And N4RF's code that is floating around several places as reference.
It's the GPS/GPRS/GSM module V3.0 with an Arduino Uno.
I have external power at 9 volts from DC power supply feeding board, and all lights are turning on and flashing.
I've been going way back to basics to try to debug this pain in the butt.
If I use the most simple code while the UART is switched to GSM, The board will display the following within 8-9 seconds.
+CFUN: 1
+CPIN: READY
+PACSP: 1
Call Ready
GPS Ready
After that I can in that instance Start GPS into Autonomy, then query it for data and subsequently send a text saying whatever I want... So I know that mode works.
the wiki code to deliver an SMS or to vomit the code up on serial monitor also appear to work.
I have a whole huge long thing that I wrote based off of the "GPS controlled with Arduino" code that which appears to just hang somewhere but I can't figure out where. So I started stripping everything back to just try to get the UTC Time code off and text that. I can only assume that I'm making some critical error as it comes to serial communication.
So here I am with this:
It displays the following in Serial monitor/CoolTerm:
AT
AT
AT+CGPSIPR=9600
AT+CGPSPWR=1
AT+CGPSRST=1
AT+CGPSINF=0
But while all the red PWR light and the Green stat light stay on and the net light flickers about every 4 seconds... It doesn't do anything after that....
Any suggestions?
I feel pretty certain that if I can get one parameter down and texted I can handle the rest.
Thanks!
PS, did you know that if you try to search GPS GSM Arduino in the forum topics it removes each word from the search? This is because each individually is too common to be relevant... however from sifting through this I am certain that all together fit would turn up entirely relevant search topics.
However, this shield is utterly baffling me.
I like everyone else is using the wiki located here
http://www.dfrobot.com/wiki/index.php/GPS/GPRS/GSM_Module_V3.0_(SKU:TEL0051)#Trouble_shooting
And N4RF's code that is floating around several places as reference.
It's the GPS/GPRS/GSM module V3.0 with an Arduino Uno.
I have external power at 9 volts from DC power supply feeding board, and all lights are turning on and flashing.
I've been going way back to basics to try to debug this pain in the butt.
If I use the most simple code while the UART is switched to GSM, The board will display the following within 8-9 seconds.
+CFUN: 1
+CPIN: READY
+PACSP: 1
Call Ready
GPS Ready
After that I can in that instance Start GPS into Autonomy, then query it for data and subsequently send a text saying whatever I want... So I know that mode works.
the wiki code to deliver an SMS or to vomit the code up on serial monitor also appear to work.
I have a whole huge long thing that I wrote based off of the "GPS controlled with Arduino" code that which appears to just hang somewhere but I can't figure out where. So I started stripping everything back to just try to get the UTC Time code off and text that. I can only assume that I'm making some critical error as it comes to serial communication.
So here I am with this:
Code: Select all
//Declare Global Variables
char utcread[14]={'0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
void comma(char num)//get ','
{
char val;
char count=0;//count the number of ','
while(1)
{
if(Serial.available()>0)
{
val = Serial.read();
if(val==',')
count++;
}
if(count==num)
return;
}
}
void GPS_Prep()
{
Serial.println("AT");
delay (1000);
Serial.println("AT");
delay(1000);
Serial.println("AT+CGPSIPR=9600");
delay(1000);
Serial.println("AT+CGPSPWR=1");
delay(1000);
Serial.println("AT+CGPSRST=1");
//delay (100*1000); //wait 100 seconds
}
void UTC()//get the UTC data and stores as an char array "utc"
{
char i=0;//count
{
comma(4); //Wait 4 commas
while(1)
{
if(Serial.available()>0)
{
utcread[i] = Serial.read();
i++;
}
if(i==14)
{
return;
}
}
}
}
void GSM_Prep()
{
//Enable GSM with Sim Commands
Serial.println("AT"); //Send AT Command
delay (1000);
Serial.println("AT"); //Send AT Command
delay (1000);
Serial.println("AT+CMGF=1"); //Set message to text format
delay (1000);
Serial.println("AT+CMGS=\"9999999999\"");// (Yes, I know this is where my number goes.)
delay(2000);
}
void setup()
{
//Enable default Shield driver pins
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
//Output GSM timing
digitalWrite(5,HIGH);
delay(1500);
digitalWrite(5,LOW);
}
//################################################################
void loop()
{
//Enable GSM Sim Com Serial feed.
digitalWrite(3,LOW);//Enable GSM mode
digitalWrite(4,HIGH);//Disable GPS mode
delay(2000);
Serial.begin(9600);// Initialize serial communication at 9600 baud
delay(3000);// Wait for DF Robot shield to be ready
delay (10*1000); //delay 10 seconds for initialization
GPS_Prep();
Serial.println("AT+CGPSINF=0"); //Request info from GPS
UTC(); //Read Universal Time Code
GSM_Prep(); //Prep to send text
for(int i=0; i<=13; i++){
Serial.print(utcread[i]);
}
Serial.write(26);
while(1);
}
It displays the following in Serial monitor/CoolTerm:
AT
AT
AT+CGPSIPR=9600
AT+CGPSPWR=1
AT+CGPSRST=1
AT+CGPSINF=0
But while all the red PWR light and the Green stat light stay on and the net light flickers about every 4 seconds... It doesn't do anything after that....
Any suggestions?
I feel pretty certain that if I can get one parameter down and texted I can handle the rest.
Thanks!
PS, did you know that if you try to search GPS GSM Arduino in the forum topics it removes each word from the search? This is because each individually is too common to be relevant... however from sifting through this I am certain that all together fit would turn up entirely relevant search topics.
2015-04-15 14:06:11 Had you read my original post you would know that I've been trying to do exactly that.
anonymous
leff wrote:Hi Matthias,
well, then why not have a try about the wiki page tutorial: How to SMS by arduino & GPS sketch, add them together to make it go![]()

2015-04-08 08:57:04 Hi Grey and Jose,
Thanks for your help. I've included my most recent code below.
I had already used the wiki to do USB and Arduino control of both GSM and GPS before my las message so I know the shield is fine.
I have since adapted N4RF's code posted elsewhere to send SMS from GPS data.. It's super cumbersome but it worked as a sort of first order approximation. The values are incorrect by a quarter mile, but that's a function of N4RF not using the correct variables I think. At any rate, that is irrelevant for our purposes Degree Decimal Minutes is perfectly appropriate for our output so I'm not worrying about that.
However, there are still several problems:
First:
In a prior version, even though there is a conditional that requires lat/long data in order to send a message. It will return one empty result by text before it sends the first data... This is possibly still an issue, In trying to fix it, I'm not sure I've run into other bigger ones.
Second, Altitude and UTC time is wildly inconsistent and inaccurate It often thinks we are in the year 2034 and that our altitude is -3-7 meters. I'm close to sea-level but by no means underwater. I don't know if this is some GPS/GIS joke about where my current altitude will be in 20 years but it's not going to work for this project. I added the date and time commands using <AT+CCLK?> And that will send correctly.. but now no lat or long data is produced... It is clearly reading the AT+CCLK? and parsing it into the appropriate char, then recalling and sending it.. but not working for the GPS data.
Am I running up against memory limits? it seems unlikely given that I'm only using approximately 30% of the available space...
anonymous
Thanks for your help. I've included my most recent code below.
I had already used the wiki to do USB and Arduino control of both GSM and GPS before my las message so I know the shield is fine.
I have since adapted N4RF's code posted elsewhere to send SMS from GPS data.. It's super cumbersome but it worked as a sort of first order approximation. The values are incorrect by a quarter mile, but that's a function of N4RF not using the correct variables I think. At any rate, that is irrelevant for our purposes Degree Decimal Minutes is perfectly appropriate for our output so I'm not worrying about that.
However, there are still several problems:
First:
In a prior version, even though there is a conditional that requires lat/long data in order to send a message. It will return one empty result by text before it sends the first data... This is possibly still an issue, In trying to fix it, I'm not sure I've run into other bigger ones.
Second, Altitude and UTC time is wildly inconsistent and inaccurate It often thinks we are in the year 2034 and that our altitude is -3-7 meters. I'm close to sea-level but by no means underwater. I don't know if this is some GPS/GIS joke about where my current altitude will be in 20 years but it's not going to work for this project. I added the date and time commands using <AT+CCLK?> And that will send correctly.. but now no lat or long data is produced... It is clearly reading the AT+CCLK? and parsing it into the appropriate char, then recalling and sending it.. but not working for the GPS data.
Am I running up against memory limits? it seems unlikely given that I'm only using approximately 30% of the available space...
Code: Select all
// Author: Matthias Elliott
// Organization: St Petersburg Makers
// Program Name: TeguTag
// Version: 0.2
// Board: Arduino Uno SMD
// Shield Manufacturer: DF Robot
// Shield Model: TEL0051 GPS/GPRS/GSM Module V.30
/*
Description:
This sketch was created as a preliminary to an open source arduino based GPS tag for
Florida Fish and Wildlife Commission to track Tegu Lizards for research.
It is a first blush synthesis program based on the code produced by N4RF and shared by HuoSen:
http://github.com/DFRobot/GPS-GPRS-GSM-Shield-V3.0/blob/master/geoLocator/Arduino%20/GPRS_GPS.ino
And modified using the instruction and examples provided by DfROBOT at:
https://www.dfrobot.com/wiki/index.php/GPS/GPRS/GSM_Module_V3.0_(SKU:TEL0051)
##############################################################
The sketch is designed to do the following actions:
Activate GPS
Scan until a fix is established.
Parse Lat Long (Degree Decimal Minutes) Altitude, and UTC (hhmmss) fix length and send via GSM text to a cell phone.
###############################################################
###############################################################
Installation Steps:
1)Turn S1 Switch to "Prog"
2)Turn S2 Switch to "Arduino"
3) Set UART switch to center.
4) Upload sketch
5) Turn s1 to "Arduino"
6) Reset the board.
###############################################################
Work to do:
###############################################################
1)
2)
3) Fix lat/long, time to fix and sats
4) Transition delays to timer commands.
5) Add SD Card write
6) Incorprate rocketscream low power library and/or external watchdog timer
7) Remove debugging commands
###############################################################
Released under Creative Commons Attribution-ShareAlike 3.0 License.
###############################################################
*/
//Declare Global Variables
char aux_str[55];
char aux;
char inChar;
int index;
char inData[200];
char latitude[15];
char longitude[15];
char DnT[20]; //Date and TIme
char ttFF[3]; //time to first fix
char Sats[2]; //gets number of satellites
void setup()
{
//Init the driver pins for GSM function
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(13, OUTPUT); //initialize
//Output GSM Timing
digitalWrite(5,HIGH);
delay(1500);
digitalWrite(5,LOW);
Serial.begin(9600);
//Enable GSM. GPS data will be controlled via AT commands through GSM
digitalWrite(3,LOW);//enable GSM TX、RX
digitalWrite(4,HIGH);//disable GPS TX、RX
delay(20000);
start_GSM();
delay(5000);
start_Data();
}
void loop()
{
read_DnT(); //pull date and time and store in char variable DnT
read_GPS(); //Read assorted lat long data and store in variables
delay(2000);
if (latitude[0] == '0' && longitude[0] == '0')
{
for (int i=0; i<5; i++) //4 quick blinks to indicate reaching this point.
{
digitalWrite(13, HIGH);
delay(250);
digitalWrite(13, LOW);
delay(250);
}
send_fail();
}
else
{
for (int i=0; i<4; i++) //3 slow blinks to indicate reaching this point
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
send_data();
}
delay(3000);
}
void start_GSM(){
//Configure for text
Serial.println("AT");
delay(1000);
Serial.println("AT+CREG?");
delay(1000);
Serial.println("AT+CMGF=1");
delay(1000);
}
void send_data(){
Serial.println("AT+CMGS=\"7275129636\"");
delay(1000);
Serial.println(DnT);
Serial.print("1st GPS Fix(s):");
Serial.println(ttFF);
Serial.print("Lat(DDM):");
Serial.println(latitude);
Serial.print("Long(DDM):");
Serial.println(longitude);
Serial.print("Satellites in View:");
Serial.println(Sats);
Serial.write(26); //Ctrl-Z to close message
delay(2000);
}
void send_fail(){
// Removed because no longer needed. useful for debug
/*Serial.println("AT+CMGS=\"7275129636\"");
delay(1000);
Serial.print("No GPS fix");
Serial.write(26);
*/
delay(10000);
}
void start_Data(){
//Configuracion en Inicializacion GPS
Serial.print("AT");
delay(1000);
Serial.println("AT+CGPSIPR=9600");// (set the baud rate)
delay(1000);
Serial.println("AT+CGPSPWR=1"); // (turn on GPS power supply)
delay(1000);
Serial.println("AT+CGPSRST=1"); //(reset GPS in autonomy mode)
delay(1000);
Serial.println("AT+CTZU=1"); //Enable automatic time zone update via NITZ
delay(10*1000);
}
void read_DnT(){
char alt[9]; //temp storage for altitude
char utc[15]; // temp storage for utc
Serial.println("AT+CCLK?"); //Serial call for date and time
read_String();
strtok(inData, "\"");
strcpy(DnT, strtok(NULL, "-")); //Gets date and time
}
void read_GPS(){
char alt[12]; //temp storage for altitude
char utc[18]; // temp storage for utc
Serial.println("AT+CGPSINF=0"); //Serial call for GPS Data
read_String();
strtok(inData, ",");
strcpy(longitude,strtok(NULL, ",")); // Gets longitude
strcpy(latitude,strtok(NULL, ",")); // Gets latitude
strcpy(alt, strtok(NULL, ",")); //Gets altitude.UNUSED
strcpy(utc, strtok(NULL, ",")); //gets utc, incorrect date and time for some reason with this board UNUSED
strcpy(ttFF, strtok(NULL, ",")); //Gets time to first fix
strcpy(Sats, strtok(NULL, ",")); //Gets number of satellites in view for fix
//Convert DDMs to DDs (bad calculation repair if reincorporating)
// convert2Degrees(latitude);
//convert2Degrees(longitude);
}
void read_String() {
index=0;
while(Serial.available() > 0) // Don't read unless
// there you know there is data
{
if(index < 199) // One less than the size of the array
{
inChar = Serial.read(); // Read a character
inData[index] = inChar; // Store it
index++; // Increment where to write next
inData[index] = '\0'; // Null terminate the string
}
}
}
int8_t convert2Degrees(char* input){
float deg;
float minutes;
boolean neg = false;
//auxiliar variable
char aux[10];
if (input[0] == '-')
{
neg = true;
strcpy(aux, strtok(input+1, "."));
}
else
{
strcpy(aux, strtok(input, "."));
}
// convert string to integer and add it to final float variable
deg = atof(aux);
strcpy(aux, strtok(NULL, '\0'));
minutes=atof(aux);
minutes/=1000000;
if (deg < 100)
{
minutes += deg;
deg = 0;
}
else
{
minutes += int(deg) % 100;
deg = int(deg) / 100;
}
// add minutes to degrees
deg=deg+minutes/60;
if (neg == true)
{
deg*=-1.0;
}
neg = false;
if( deg < 0 ){
neg = true;
deg*=-1;
}
float numeroFloat=deg;
int parteEntera[10];
int cifra;
long numero=(long)numeroFloat;
int size=0;
while(1){
size=size+1;
cifra=numero%10;
numero=numero/10;
parteEntera[size-1]=cifra;
if (numero==0){
break;
}
}
int indice=0;
if( neg ){
indice++;
input[0]='-';
}
for (int i=size-1; i >= 0; i--)
{
input[indice]=parteEntera[i]+'0';
indice++;
}
input[indice]='.';
indice++;
numeroFloat=(numeroFloat-(int)numeroFloat);
for (int i=1; i<=6 ; i++)
{
numeroFloat=numeroFloat*10;
cifra= (long)numeroFloat;
numeroFloat=numeroFloat-cifra;
input[indice]=char(cifra)+48;
indice++;
}
input[indice]='\0';
}
Grey wrote:HI Matthias,
I'll reply the mail here.
Where do you get the testing code, I found it is not our wiki one. Could you try the wiki code "How to drive the GPS Mode via Arduino board". It could tell us whether the GSM shield works well.
And it is better to add a delay time in the setup function. It need some time to register on the Net.
Could you show me the result?

2015-04-07 21:14:18 Komizutama,
Welcome to the forum! How is the project going?
I didn't check yet how are you parsing the serial. But bear in mind that you have to use one device or another for the Serial port. Sometimes you can "listen" to some of the data but you might want to use a secondary serial port for debugging purposes. Check out Software serial library.
You could debug directly via SMS at a cost or use another board such as Leonardo that has 2 serial ports. I believe there is some more sample code or library for Leonardo based boards on our Github repository.
Cheers
Jose
Welcome to the forum! How is the project going?
I didn't check yet how are you parsing the serial. But bear in mind that you have to use one device or another for the Serial port. Sometimes you can "listen" to some of the data but you might want to use a secondary serial port for debugging purposes. Check out Software serial library.
You could debug directly via SMS at a cost or use another board such as Leonardo that has 2 serial ports. I believe there is some more sample code or library for Leonardo based boards on our Github repository.
Cheers

2015-04-06 00:43:44 Hi Matthias,
well, then why not have a try about the wiki page tutorial: How to SMS by arduino & GPS sketch, add them together to make it go
Leff
well, then why not have a try about the wiki page tutorial: How to SMS by arduino & GPS sketch, add them together to make it go


2015-04-04 02:32:17 HI Matthias,
I'll reply the mail here.
Where do you get the testing code, I found it is not our wiki one. Could you try the wiki code "How to drive the GPS Mode via Arduino board". It could tell us whether the GSM shield works well.
And it is better to add a delay time in the setup function. It need some time to register on the Net.
Could you show me the result?
Grey.CC
I'll reply the mail here.
Where do you get the testing code, I found it is not our wiki one. Could you try the wiki code "How to drive the GPS Mode via Arduino board". It could tell us whether the GSM shield works well.
And it is better to add a delay time in the setup function. It need some time to register on the Net.
Could you show me the result?

2015-04-03 10:39:30 I think you misunderstand. It's not working... I'm looking for help on it..
If you have a solution that'd be awesome though.
anonymous
If you have a solution that'd be awesome though.
