GPS Shield(I2C/UART)

From GOF_Wiki
Jump to: navigation, search

Contents

Introduction

If you don't have extra UART to communicate with GPS, this GPS Shield frees you up by switching to I2C interface! The GPS Shield communicates with your host Arduino over I2C or UART which simply selected by the two on-board switches. The GPS Shield is based on NewStar GPS module which features the high performance u-blox 6 positioning engine. The 50-channel u-blox 6 positioning engine(UB-6010 chipset) boasts a Time-To-First-Fix (TTFF) of under 1 second and dedicated acquisition engine, with over 1 million correlators, is capable of massive parallel time/frequency space searches, enabling it to find satellites instantly.

Module: M2011051101

GPS shieldone.jpg

Features

Specifications

Receiver Type L1 frequency band, C/A code, 50-channels
SBAS: WAAS, EGNOS, MSAS, GAGAN
Sensitivity Tracking -160dBm
Acquisition -160dBm
Accuracy Position 5m CEP without SA
Velocity 0.1m/s without SA
Timing (PPS) 10ns RMS
Acquisition Time Cold Start 29s
Warm Start 28s
Hot Start 1s
Re-Acquisition <1s
Power Consumption Tracking 35mA @3V
Acquisition 40mA
Sleep/Standby TBD
Operational Limits Altitude Max 18,000m
Velocity Max 515m/s
Acceleration Less than 4g
Communication Protocol UART 9600bps(Default)
I2C <100kbit/s
Power supply 5V from Arduino board
VDD 3.3V (for GPS Module)
Mechanic Dimension 69.3mm X53.5mm X 19.6mm
RoHS Yes

Application Ideas

Cautions

  • The NewStar GPS module is not designed for life saving or supporting devices or for aviation and should not be used in products that could in any way negatively impact the security or health of the user or third parties or that could cause damage to goods.
  • Two Mode Switches should always on the same side for GPS shield to work properly.

Hardware Diagram

GPSHWDM.jpg

Getting Started

GetStart.jpg
Easy steps to get your GPS Shield started

UART Mode and I2C Mode Switches

There are two on-board mode switches in the GPS Shield for users to select UART mode or I2C mode. If the two switches both on the I2C side, the GPS data will access by the host Arduino from I2C Port, and the I2C of GPS module is connect to the Analog Pin A4(SDA) and A5(SCL) which is the I2C Port of the Arduino 328/168. So if you want to use this GPS shield on Arduino MEGA in I2C mode, you need to wire them to Digital Pin 20(SDA) and 21(SCL) of MEGA.

If the two switches both on the UART side, the GPS data will access by the host Arduino from UART Port. When users decide to use UART mode to communicate, jumpers need to be used to connect the GPS_TX and GPS_RX pins of GPS Module to any D0, D1, D4~D7 pin of Arduino(refer to Selectable UART connection).

Selectable UART connection

Users can use the jumpers to connect the GPS_TX and GPS_RX pins(5V) of GPS Module to any D0, D1, D4~D7 pin of Arduino. GPScom1.jpg

Users must be aware that which Digital pin of Arduino connects to GPS_TX needs to act as Arduino RX pin(Hardware/Software), and which connects to GPS_RX needs to act as Arduino TX pin(Hardware/Software).

The following figure shows users how to use jumpers to configure UART communication between GPS Shield and Arduino. GPScomHS.jpg

Indicator LEDs

There are three indicator LEDs(PWR(Green), RES(Red), TPS(Red)) on the Wifi Shield, users can know about the working phase of the shield based on the four indicator LEDs. Detailed information please refer to the following table:

LEDs(color) Status Description
PWR(Green) ON Power of the GPS Shield is on
OFF Power of the GPS Shield is off
TPS(Red) OFF --
Blink(-1-) --
RES(Red) ON While pushing the Reset Button
OFF No pushing the Reset Button

Reset Button

The GPS Shield has a Reset button for users to reset the host Arduino if necessary. The Reset Button can not reset the GPS module. While you push the Reset button, the indicator LED RES(red) will blink to indicate that reset of the host Arduino has occured.

Antenna Interface

We design two kinds of Antenna Interface on the GPS Shield -- SMA RF connector and U.FL SMD connector, which makes it flexible for users' antenna choice -- passive or active antennas.

The following talbe is for Active Antenna Recommendations:

Antenna Type Parameter Specification
Active Antenna Minimum gain 15 - 20 dB (to compensate signal loss in RF cable)
Maximum noise figure 1.5 dB
Maximum gain 50 dB

Test Point

There are three Test Point in the GPS Shield for users' debug purpose. The following talbe is for details of the three Test Point:

Test Point Description
T1 GPS module power(+3V3) enable input: default HIGH(+5V)--enable, LOW(GND)--disable
T2 TimePluse pin of GPS module(3V3 logic)
T3 EXTINT0 pin of GPS module(3V3 logic)

Boot-time Configuration

The configuration pins of the GPS module for boot-time configuration are broken-out to Boot-time Configuration Solder Jampers on the shield. These become effective immediately after start-up. Once the module has started, the configuration settings can be modified with UBX configuration messages. The modified settings remain effective until power-down or reset. If these settings have been stored in battery-backup RAM, then the modified configuration will be retained, as long as the backup battery supply is not interrupted.

The GPS Shield includes CFG_GPS0, CFG_COM0 and CFG_COM1 solder jampers. CFG_COM0 and CFG_COM1 solder jampers can be configured as seen in the following Table. Default settings is in bold.

CFG_COM1 CFG_COM0 Protocol Messages UARTBaud rate USB power
Un-soldered Un-soldered NMEA GSV, RMC, GSA, GGA, GLL, VTG, TXT 9600 BUS Powered
Un-soldered Soldered NMEA GSV, RMC, GSA, GGA, GLL, VTG, TXT 38400 Self Powered
Soldered Un-soldered NMEA GSV, RMC, GSA, GGA, VTG, TXT 4800 BUS Powered
Soldered Soldered NMEA NAV-SOL, NAV-STATUS, NAV-SVINFO, NAV-CLOCK, INF, MON-EXCEPT, AID-ALPSERV 57600 BUS Powered


The CFG_GPS0 solder jampers , which enables the boot-time configuration of the power mode. These settings are described in following Table. Default settings in bold.

CFG_GPS0 Power Mode
Un-soldered Maximum Performance Mode
Soldered Eco Mode

Prototype Area

There is Prototype Area on the GPS Shield for users add your own circuitry or components to the shield. The Prototype Area is 2.54mm (100mil) spaced holes with 3V3, +5V power and GND. It will be very convenient for adding through-hole components while 3V3 and +5V power on the board.

Examples

Getting GPS Data in UART Mode

Set the two mode switches BOTH on the UART side, using jumpers to connect GPS_RX to D7 of Arduino UNO, GPS_TX to D6 of UNO. Then upload the following sketch to UNO.

#include <SoftwareSerial.h>
 
SoftwareSerial gps(6,7);//RX-6;TX-7
 
char data;
 
void setup()
{
  Serial.begin(9600);
  gps.begin(9600);
}
 
void loop()
{
  if(gps.available() > 0) {
    data = gps.read();
    Serial.print(data);
  }
}

Nornally it will take 30s for GPS module to get the location data(time may be longer based on the weather). When the location data is ready, the TPS led will blink in 1Hz. And you can see the lacation data from the Arduino IDE'S serial monitor as follows:

UARTDATA.jpg

Getting GPS Data in I2C Mode

Set the two mode switches BOTH on the I2C side, no need of using jumpers. Then upload the following sketch to UNO.


#include <Wire.h>
 
#define BUFFER_LENGTH 10//buffer size
 
int GPSAddress = 0x42;//GPS address
 
double Datatransfer(char *data_buf,char num)//transfer:char to float
 
{                                           //*data_buf:char need to be converted;num:scalar
 
  double temp=0.0;
 
  unsigned char i,j;
 
  if(data_buf[0]=='-')//negative number
 
  {
 
    i=1;
 
    //char to int and accumulation
    while(data_buf[i]!='.')
 
      temp=temp*10+(data_buf[i++]-0x30);
 
    for(j=0;j<num;j++)
 
      temp=temp*10+(data_buf[++i]-0x30);
 
    //int to float
    for(j=0;j<num;j++)
 
      temp=temp/10;
 
    //convert to negetive number
    temp=0-temp;
 
  }
 
  else//positive number
 
  {
 
    i=0;
 
    while(data_buf[i]!='.')
 
      temp=temp*10+(data_buf[i++]-0x30);
 
    for(j=0;j<num;j++)
 
      temp=temp*10+(data_buf[++i]-0x30);
 
    for(j=0;j<num;j++)
 
      temp=temp/10 ;
 
  }
 
  return temp;
 
}
 
void rec_init()//receive initialization
 
{
 
  Wire.beginTransmission(GPSAddress);
 
  Wire.send(0xff);//load address of the bytes    
 
  Wire.endTransmission();
 
  Wire.beginTransmission(GPSAddress);
 
  Wire.requestFrom(GPSAddress,10);//require 10 byte from GPA
 
}
 
char ID()//info ID
 
{
 
  char i = 0;
 
  char value[7]={
 
    '$','G','P','G','G','A',','      };//the info ID
 
  char buff[7]={
 
    '0','0','0','0','0','0','0'      };
 
  while(1)
 
  {
 
    rec_init();//receive initialize
 
    while(Wire.available()) 
 
    {
 
      buff[i] = Wire.receive();//get I2C data
 
      if(buff[i]==value[i])//compare
 
      {
 
        i++;
 
        if(i==7)
 
        {
 
          Wire.endTransmission();//end of transmission
 
          return 1;//if end return 1
 
        }
 
      }
 
      else
 
        i=0;
 
    }
 
    Wire.endTransmission();//end of transmission
 
  }
 
}
 
void UTC()//get time info
 
{
 
  char i = 0,flag=0;
 
  char value[7]={
 
    '$','G','P','G','G','A',','   };
 
  char buff[7]={
 
    '0','0','0','0','0','0','0'       };
 
  char time[9]={
 
    '0','0','0','0','0','0','0','0','0'    };//time buffer
 
  double t=0.0;
 
  while(1)
 
  {
 
    rec_init();  
 
    while(Wire.available()) 
 
    {
 
      if(!flag)
 
      {
 
        buff[i] = Wire.receive();
 
        if(buff[i]==value[i])
 
        {
 
          i++;
 
          if(i==7)
 
          {
 
            i=0;
 
            flag=1;
 
          }
 
        }
 
        else
 
          i=0;
 
      }
 
      else
 
      {
 
        time[i] = Wire.receive();
 
        i++;
 
        if(i==9)
 
        {
 
          t=Datatransfer(time,2);//convert to float
 
          t=t+80000.00;//change to BeiJing time
 
          Serial.println(t);//print time
 
          Wire.endTransmission();
 
          return;
 
        }
 
      }
 
    }
 
    Wire.endTransmission();
 
  }
 
}
 
void rec_data(char *buff,char num1,char num2)//receive data
 
{                                            //*buff:receive buffer;num1:num of comma;num2:size of buff。
 
  char i=0,count=0;
 
  if(ID())
 
  {
 
    while(1)
 
    {
 
      rec_init();  
 
      while(Wire.available()) 
 
      {
 
        buff[i] = Wire.receive();
 
        if(count!=num1)
 
        {
 
          if(buff[i]==',')
 
            count++;
 
        }
 
        else
 
        {
 
          i++;
 
          if(i==num2)
 
          {
 
            Wire.endTransmission();
 
            return;
 
          }
 
        }
 
      }
 
      Wire.endTransmission();
 
    }
 
  }
 
}
 
void latitude()//get latitude info
 
{
 
  char lat[10]={
 
    '0','0','0','0','0','0','0','0','0','0' };//latitude buffer
 
  rec_data(lat,1 ,10);//get latitude data
 
  Serial.println(Datatransfer(lat,5),5);//convert to float
 
}
 
void lat_dir()//get latitude direction info
 
{
 
  char dir[1]={'0'};//latitude direction buffer
 
  rec_data(dir,2,1);//get direction data
 
  Serial.println(dir[0],BYTE);//print the data
 
}
 
void  longitude()//get longtitude info
 
{
 
  char lon[11]={
 
    '0','0','0','0','0','0','0','0','0','0','0' };//longtitude buffer
 
  rec_data(lon,3,11);//get longitude data
 
  Serial.println(Datatransfer(lon,5),5);//convert data to float
 
}
 
void lon_dir()//get longitude direction info
 
{
 
  char dir[1]={'0'};
 
  rec_data(dir,4,1);
 
  Serial.println(dir[0],BYTE);
 
}
 
void altitude()//get altitude info
 
{
 
  char i=0,count=0;
 
  char alt[8]={
 
    '0','0','0','0','0','0','0','0' };
 
  if(ID())
 
  {
 
    while(1)
 
    {
 
      rec_init();  
 
      while(Wire.available()) 
 
      {
 
        alt[i] = Wire.receive();
 
        if(count!=8)
 
        {
 
          if(alt[i]==',')
 
            count++;
 
        }
 
        else
 
        {
 
          if(alt[i]==',')
 
          {
 
            Serial.println(Datatransfer(alt,1),1);
 
            Wire.endTransmission();
 
            return;
 
          }
 
          else
 
            i++;
 
        }
 
      }
 
      Wire.endTransmission();
 
    }
 
  }
 
}
 
void setup()
 
{
 
  Wire.begin();//I2C initialize
 
  Serial.begin(9600);//set baudrate
 
  Serial.println("GOF GPS Shield v1.0");
 
  Serial.println("$GPGGA statement information: ");
 
}
 
void loop()
 
{
 
  while(1)
 
  {
 
    Serial.print("UTC:");
 
    UTC();
 
    Serial.print("Lat:");
 
    latitude();
 
    Serial.print("Dir:");
 
    lat_dir();
 
    Serial.print("Lon:");
 
    longitude();
 
    Serial.print("Dir:");
 
    lon_dir();
 
    Serial.print("Alt:");
 
    altitude();
 
    Serial.println(' ');
 
    Serial.println(' ');
 
  }
 
}

You can see the lacation data from the Arduino IDE'S serial monitor as follows:

I2CDATA.jpg

Schematics

Schematic of GPS shield

Resources

Datasheet

Reference:u-blox5_Protocol_Specifications(GPS.G5-X-07036).pdf

NewSoftLibrary

Serial Terminals(sscom32)

How to buy

GPS Shield can be ordered through the GOF store. Its product page is located here

See Also

Licensing

This documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 Source code and libraries are licensed under GPL/LGPL, see source code files for details.

Personal tools
Variants
Actions
Navigation
Support
Toolbox