
Introduction
In this tutorial we are going to introduce the use of ARDUINO with GPRS and GPS. We will use the Arduino Quadband Mobile Navigator Pack.This pack includes almost all the ingredients neccesary for this proyect. This small example will let you to know the possition of any arduino board and send this data through GPRS.
Ingredients:
- 1 x Arduino Quadband Mobile Navigator Pack
- 1 x GPS Antenna
- 1 x GPRS Antenna
- 1 x Two small wires (Red an Black)
- 1 x USB cable
- 1 x PC
Difficulty: Medium -
Preparation Time: 30 minutes
Previous knowledge:
Tutorial GPS module
Tutorial GPRS module
Steps Index
Step 1: The Arduino Quadband Mobile Navigator Pack (hardware):
The pack we are going to use in this tutorial is the Arduino Quadband Mobile Navigator from Cooking hacks.
The GPRS/GPS shield is fully compatible with old Arduino USB versions, Duemilanove and Mega.
GPRS/GPS Pack diagram:


Connecting the module to an Arduino Remember, the serial communication jumpers have to be set on Arduino position.
If we connecting the module to a PC directly (using an Arduino as gateway), we should set the jumpers on USB gateway position.
Step 2 : Connecting and powering the pack.
Connect the GPS to Arduino as shown in the picture. Once the GPS is connected, you have to connect power to it. Using two small wires (red for 5V and black for GND).



Use an external power supply and place the power jumpers in the right position. If the shield is powered from the Arduino, the power jumper must be in Arduino 5V position. It the shield is powered from the Vin input (in the shield), the power jumper must be in Vext position.
If you use a power supply with output smaller than 2 A, you should add an extra capacitor for the power. For example, a 220 uF electrolytic capacitor between 3.3V and GND.
Power supply jumper should be set to Arduino 5V position if you are using 12 volt power supply directly connected to Arduino. (Because the Arduino power the module)




Step 3 : Sending SMS with GPS data.
Connecting the pack to an Arduino and using the code below, Arduino sends an SMS with GPS data. Remember, now the serial communication jumpers have to be set on Arduino position.
/*
Sending SMS with GPS dataSend SMS every two minutes with GPS data of the position (latitude, longitude and altitude).
Ingredients:
* Arduino Quadband Mobile Navigator Pack
* Two small wires (red for 5V and black for GND)created 1 Jul. 2010
by Marcos Yarza
Modified 17 Feb. 2012
by Luis MartnThis example code is in the public domain.
*/
// Include the SoftwareSerial library for the GPS connection
#include// Constants
#define rxPin 9 //rx pin in gps connection
#define txPin 8 //tx pin in gps connection// Set up the serial port
SoftwareSerial gps = SoftwareSerial(rxPin, txPin);byte byteGPS = 0;
int i = 0;
int h = 0;
int aux = 0;char GPS_GGA[100]="";
char longitude[12]="";
char latitude[12]="";
char altitude[12]="";
int fix = 0;int onModulePin = 2;
void switchModule(){
digitalWrite(onModulePin,HIGH);
delay(2000);
digitalWrite(onModulePin,LOW);
}void setup(){
Serial.begin(9600);
// Setup for mySerial port
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
gps.begin(4800);// Swith the module ON
switchModule();
delay(10000);// Set the SMS mode to text
Serial.println("AT+CMGF=1");while(Serial.read() != 'K'){
}
Serial.println("OK");Serial.print("AT+CSCS=");
Serial.print(34,BYTE);
Serial.print("IRA");
Serial.println(34,BYTE);while(Serial.read() != 'K'){
}
Serial.println("OK");
}void loop(){
// Read GGA sentence from GPS
byteGPS = gps.read();
while(byteGPS != 'G'){
byteGPS = gps.read();
}
byteGPS = gps.read();
if (byteGPS == 'G'){GPS_GGA[0]='$';
GPS_GGA[1]='G';
GPS_GGA[2]='P';
GPS_GGA[3]='G';
GPS_GGA[4]='G';i = 5;
while(byteGPS != 10){
byteGPS = gps.read();
GPS_GGA[i]=byteGPS;
i++;
}i = 0;
while(GPS_GGA[i]!=','){
latitude[i]=GPS_GGA[i];
i++;
}
i++;
while(GPS_GGA[i]!=','){
i++;
}
i++;// Get Latitude
aux = 0;
while(GPS_GGA[i]!=','){
latitude[aux]=GPS_GGA[i];
i++;
aux++;
}
i++;
latitude[aux]=GPS_GGA[i];
i++;
i++;// Get Longitude
aux = 0;
while(GPS_GGA[i]!=','){
longitude[aux]=GPS_GGA[i];
i++;
aux++;
}
i++;
longitude[aux]=GPS_GGA[i];
i++;
i++;
fix = GPS_GGA[i]-48;
i++;
i++;
while(GPS_GGA[i]!=','){
i++;
}
i++;
while(GPS_GGA[i]!=','){
i++;
}
i++;// Get Altitude
aux = 0;
while(GPS_GGA[i]!=','){
altitude[aux]=GPS_GGA[i];
i++;
aux++;
}
}// If fix = 1 (satellites connected) send the message
if (fix == 1){
Serial.print("AT+CMGS=");
Serial.print(34,BYTE);/******************************************************************************
********* is the number of the mobile to send the SMS
******************************************************************************/
Serial.print("*********");
Serial.println(34,BYTE);
delay(1500);
Serial.print("My coordinates are: ");
Serial.print("Latitude: ");
i = 0;
while(latitude[i]!=0){
Serial.print(latitude[i],BYTE);
i++;
}
Serial.print(" | Longitude: ");
i = 0;
while(longitude[i]!=0){
Serial.print(longitude[i]);
i++;
}
Serial.print(" | Altitude: ");
i = 0;
while(altitude[i]!=0){
Serial.print(altitude[i]);
i++;
}
Serial.print(" m");
Serial.print(0x1A,BYTE);while(Serial.read() != 'K'){
}Serial.println("\nEnviado");
// Send the message every 2 minutes
delay(120000);
}
}
Upload the code to Arduino and watch the Serial monitor.


If your GPRS module doesn't answer, maybe it is configured in a different baudrate. Try different baudrates in Serial.begin() (9600, 19200, 34800, 57600, 115200) until you get to communicate.
You can configure the baudrate in gateway mode. Refer for the GPRS tutorial (Step 2) for more information.
Step 4 : Sending GPS data to TCP/IP server.
Connecting the pack to an Arduino and using the code below, Arduino sends GPS data to a TCP/IP server. Remember, now the serial communication jumpers have to be set on Arduino position.
To use this code, you must have opened the TCP port of the router you will use.
/*
Sending GPS data to TCP/IP serverSend data of the position (latitude, longitude and altitude) to TCP/IP server GPS .
Ingredients:
* Arduino Quadband Mobile Navigator Pack
* Two small wires (red for 5V and black for GND)Created 17 Feb. 2012
by Luis MartinThis example code is in the public domain.
*/
// Include the SoftwareSerial library for the GPS connection
#include// Constants
#define rxPin 9 //rx pin in gps connection
#define txPin 8 //tx pin in gps connection// Set up the serial port
SoftwareSerial gps = SoftwareSerial(rxPin, txPin);byte byteGPS = 0;
int i = 0;
int h = 0;
int aux = 0;char GPS_GGA[100]="";
char longitude[12]="";
char latitude[12]="";
char altitude[12]="";
int fix = 0;int onModulePin = 2;
void switchModule(){
digitalWrite(onModulePin,HIGH);
delay(2000);
digitalWrite(onModulePin,LOW);
}void setup(){
Serial.begin(9600);
// Setup for mySerial port
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
gps.begin(4800);// Swith the module ON
switchModule();
delay(20000);}
void loop(){
// Read GGA sentence from GPS
byteGPS = gps.read();
while(byteGPS != 'G'){
byteGPS = gps.read();
}
byteGPS = gps.read();
if (byteGPS == 'G'){GPS_GGA[0]='$';
GPS_GGA[1]='G';
GPS_GGA[2]='P';
GPS_GGA[3]='G';
GPS_GGA[4]='G';i = 5;
while(byteGPS != 10){
byteGPS = gps.read();
GPS_GGA[i]=byteGPS;
i++;
}i = 0;
while(GPS_GGA[i]!=','){
latitude[i]=GPS_GGA[i];
i++;
}
i++;
while(GPS_GGA[i]!=','){
i++;
}
i++;// Get Latitude
aux = 0;
while(GPS_GGA[i]!=','){
latitude[aux]=GPS_GGA[i];
i++;
aux++;
}
i++;
latitude[aux]=GPS_GGA[i];
i++;
i++;// Get Longitude
aux = 0;
while(GPS_GGA[i]!=','){
longitude[aux]=GPS_GGA[i];
i++;
aux++;
}
i++;
longitude[aux]=GPS_GGA[i];
i++;
i++;
fix = GPS_GGA[i]-48;
i++;
i++;
while(GPS_GGA[i]!=','){
i++;
}
i++;
while(GPS_GGA[i]!=','){
i++;
}
i++;// Get Altitude
aux = 0;
while(GPS_GGA[i]!=','){
altitude[aux]=GPS_GGA[i];
i++;
aux++;
}
}// If fix = 1 (satellites connected) send GPS data
if (fix == 1){
//Set GPRS parameters (APN, login, password...
Serial.print("AT+KCNXCFG=0,");
Serial.print(34,BYTE);
Serial.print("GPRS");
Serial.print(34,BYTE);
Serial.print(",");
Serial.print(34,BYTE);/******************************************************************************
********* is your APN name (for example "internetmas")
******************************************************************************/
Serial.print("*********");
Serial.println(34,BYTE);
delay(10000);//Set TCP address and port number
Serial.print("AT+KTCPCFG=0,0,");
Serial.print(34,BYTE);
Serial.print("89.130.98.58");
Serial.print(34,BYTE);
Serial.println(",60000");
delay(10000);// Initiate the connection
Serial.println("AT+KTCPCNX=1");delay(15000);
//Send TCP data after “CONNECT”. Do not forget the PATTERN characters
Serial.println("AT+KTCPSND=1,12");delay(15000);
do{
//Send GPS data
Serial.print("My coordinates are: ");
Serial.print("Latitude: ");
i = 0;
while(latitude[i]!=0){
Serial.print(latitude[i],BYTE);
i++;
}
Serial.print(" | Longitude: ");
i = 0;
while(longitude[i]!=0){
Serial.print(longitude[i]);
i++;
}
Serial.print(" | Altitude: ");
i = 0;
while(altitude[i]!=0){
Serial.print(altitude[i]);
i++;
}
Serial.print(" m");
Serial.println();//Send data every 20 sec.
delay(20000);} while(1);
//Close data connection
//print("--EOF--Pattern--");//Close TCP connection
// println("AT+KTCPCLOSE=1,1");}
}
Upload the code to Arduino and watch the Serial monitor and the Ubuntu terminal (TCP/IP connection).


Step 5 : Important Issues.
- It is necessary an antenna in order to establish a communication.
- Handle with care the internal antenna. It's fragile.
- The GPS/GPRS pack should be inside a plastic box, isolated from the environment.
- The GPS antenna must be in horizontal position.
- For improving the satellites signal, the antenna has to be in a place with a clear sky view (no trees, no buildings...).
- Maybe the GPS module takes 2-3 minutes to get signal the first time.
Links and Documentation
- GPS schematic
- GPRS schematic
- GPS module firmware documentation
- NMEA
- AT commands manual
- GPS Module for Arduino Video-Tutorial
- GPRS Module for Arduino Video-Tutorial
If you are searching for Wireless Sensor Networks devices (motes) you may be interested in our ready to market sensor platform: Waspmote. You can discover the differences between both platforms in the document: Waspmote vs SquidBee.





