Hookup Guide and Simple Test

Introduction

The Duinopeak GPS Logger Shield equips your Arduino with access to a GPS module, µSD memory card socket, and all of the other peripherals you’ll need to turn your Arduino into a position-tracking, speed-monitoring, altitude-observing wonder logger.

The shield is based around a uBlox NEO-6M/M8N GPS Module – a 66-channel GPS receiver and an up to 10Hz update rate. The GPS module will stream constant position updates over a simple serial UART, which you can then log to a µSD card and/or use for other position or time-tracking purposes.

Everything on the shield is highly configurable: A switch allows you to select the GPS module’s UART interface between either hardware or software ports, the µSD card operates over a hardware SPI port, which should be compatible with most Arduino layouts, and extra prototyping space should allow you to add those last, few components you need to complete your project.

Selecting the Serial Port

The GPS module communicates via a simple, UART (serial) interface. The UART-select switch allows you to switch that interface between either the Arduino’s hardware UART – on pins D0 and D1 – or a SoftwareSerial port on pins D2 to D7.

Should you need a reference, this table shows the map between GPS module and Arduino UART(s):

 

GPS Pin Arduino Software UART Pin Arduino Hardware UART Pin
RX 2 1 (TX)
TX 3 0 (RX)

 

If you’re using an Arduino Uno or any development board with one, pre-occupied hardware UART, you may be forced to use the software serial port. Fortunately, the GPS module’s baud rate defaults to a slow, steady 9600 bps, which SoftwareSerial shouldn’t have a problem handling.

If you need to change the software serial port pins, they can be custom-set to any other pin by setting the jumpers between pinsD2 to D7.

Power and GPS Fix Status LEDs

This pair of LEDs on the corner of the shield are a handy tool for initial troubleshooting. The green PWR LED is attached to the output of the shield’s on-board 3.3V regulator. If the shield is getting power, this LED should be on.

The red GPS FIX LED is connected the  GPS module's “FIX” pin. It can be used to identify whether the GPS module has a proper fix or not. When you initially power the shield up, the LED should blink – indicating it’s trying to find a fix and you can rest assured that your GPS module has a good fix on your location.

Hardware Setup

Just stack the GPS Logger Shield on the Peakduino/Arduino UNO,  plug the external active GPS antenna, and plug the USB cable to power up the board.  Then check the green power LED is light on, then everythis is OK.

Note: Make sure your external antenna has a good sight to receive the GPS signal, it is recommend to put the antenna outside the window of your room. NEO-6M is need for this step, NEO-M8N is able to position in the room in the most of the time.

Software Setup

Simple Sketch: GPS Serial Passthrough

Now that your hardware is all set up, we have three pieces of example code to give you a taste of the GPS Logger Shield’s functionality. This first example isn’t all that useful, but it will, at least, make sure everything’s working. Plus it’ll show you the raw ugliness of NMEA GPS strings and make you appreciate great libraries like TinyGPS even more.

This example doesn’t require any additional libraries. Simply plug the shield into your Arduino and upload the example code. We’ve got a couple examples, depending on which Arduino and/or serial port you’re using.

SoftwareSerial Port Example

If you’re using an Arduino Mega, Arduino Uno, Redboard, any other ATmega328P-based Arduino, and have the UART-select jumpers in the SoftwareSerial position(TX-D2 and RX-D3), upload this piece of example code to your Arduino:

/******************************************************************************
This example uses SoftwareSerial to communicate with the GPS module on
pins 8 and 9. SoftwareSerial should work on most Arduinos, but it's a
necessity on Arduino Mega's, Arduino Uno's, RedBoard's and any other Arduino
based around an ATmega328P.

After uploading the code, open your serial monitor, set it to 9600 baud, and
watch the GPS module's NMEA strings begin to flow by. See if you can pick
out the latitude and longitude.
******************************************************************************/

#include <SoftwareSerial.h> // Include the SoftwareSerial library
#define ARDUINO_GPS_RX 3 // Arduino RX pin connected to GPS TX
#define ARDUINO_GPS_TX 2 // Arduino TX pin connected to GPS RX
#define GPS_BAUD_RATE 9600 // The GPS Shield module defaults to 9600 baud
// Create a SoftwareSerial object called gps:
SoftwareSerial gpsPort(ARDUINO_GPS_TX, ARDUINO_GPS_RX);

// We'll also define a more descriptive moniker for the Serial Monitor port.
// This is the hardware serial port on pins 0/1.
#define SerialMonitor Serial

void setup() 
{
  gpsPort.begin(GPS_BAUD_RATE);
  SerialMonitor.begin(9600);
}

void loop() 
{
  if (gpsPort.available()) // If GPS data is available
    SerialMonitor.write(gpsPort.read()); // Read it and print to SerialMonitor
  if (SerialMonitor.available()) // If SerialMonitor data is available
    gpsPort.write(SerialMonitor.read()); // Read it and send to GPS
}

This example uses the SoftwareSerial library to communicate with the GPS module, and leaves the hardware serial port for debugging with the serial monitor.

Open up your serial monitor and set the baud rate to 9600. You should immediately begin to see GPS NMEA data begin to flow by at a rate of 1Hz.

For example, one set of strings may look like:

Now we could use uBlox's GUI tool to view the GPS stream data visually.

Dowload the GUI tool from uBlox's website and install it.

Choose your COM port of your Arduino board and click the magic wand for autobauding.

Now, wait a second for the GPS to fix, the TP LED should blink. The blow visual data is indoor positioning(NEO-M8N only, NEO-6M must position outdoor), outdoor will be more fast and effective.

Hardware Serial Port Example

If you use Peaduino UNO Geek Edition, just very simple, set the UART-select jumpers in the HardwareSerial position(TX-D0 and RX-D1) then slide the FTDI switch to "MCU OFF", open the Serial monitor you will get the GPS stream.

Open up your serial monitor and set the baud rate to 9600. You should immediately begin to see GPS NMEA data begin to flow by at a rate of 1Hz.

For example, one set of strings may look like:

If you’re using an Arduino UNO, or any other Arduino UNO compatible with no free UART on pins 0/1, set the UART-select jumpers in the HardwareSerial position(TX-D0 and RX-D1), and upload this example:

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Once you’ve uploaded the sketch, open up your serial monitor and set the baud rate to 9600. You should immediately begin to see GPS NMEA data begin to flow by at a rate of 1Hz.

For example, one set of strings may look like:

If you’re using an Arduino Leonardo, Arduino Due, Arduino Zero, or any other Arduino with a free UART on pins 0/1, set the UART-select jumpers in the HardwareSerial position(TX-D0 and RX-D1), and upload this example:

/******************************************************************************
This example uses an Arduino's hardware serial port -- on pins 0 and 1 -- to
communicate with the GPS module. 

Hardware serial should work on any Arduino's with a free hardware serial 
UART on pins 0/1. That includes Arduino Leonardo, Zero, Due, and SparkFun's
SAMD21 Dev Board.

After uploading the code, open your serial monitor, set it to 9600 baud, and
watch the GPS module's NMEA strings begin to flow by. See if you can pick
out the latitude and longitude.
******************************************************************************/

#define GPS_BAUD_RATE 9600 // The GPS Shield module defaults to 9600 baud

// Define the serial monitor port. On the Leonardo this is 'Serial'
//  but on other boards this may be 'SerialUSB'
#define SerialMonitor Serial // e.g. Arduino Leonardo
// Define the harware serial port on pins 0/1. On the Leonardo this is 'Serial1'
//  but on other boards this may be 'Serial'
#define gpsPort Serial1 // e.g. Arduino Leonardo
// See https://www.arduino.cc/en/Reference/Serial to find out which Serial ports
//  you should use in the defines above.

void setup() 
{
  SerialMonitor.begin(9600); // Initialize the serial monitor port at 9600 baud
  gpsPort.begin(GPS_BAUD_RATE); // The GPS module's default baud is 9600
}

void loop() 
{
  if (gpsPort.available()) // If GPS data is available
    SerialMonitor.write(gpsPort.read()); // Send it to the serial monitor
  if (SerialMonitor.available()) // If data is sent to the serial monitor
    gpsPort.write(SerialMonitor.read()); // send it to the GPS module
}

You may have to alter either or both of the serial port #defines at the top of the code. Refer to your development board’s datasheet or product info page for more information on which serial port is which.

Using the Serial Passthrough Sketch

Once you’ve uploaded the sketch, open up your serial monitor and set the baud rate to 9600. You should immediately begin to see GPS NMEA data begin to flow by at a rate of 1Hz.

For example, one set of strings may look like:

$GPRMC,235316.000,A,4003.9040,N,10512.5792,W,0.09,144.75,141112,,*19 $GPGGA,235317.000,4003.9039,N,10512.5793,W,1,08,1.6,1577.9,M,-20.7,M,,0000*5F $GPGSA,A,3,22,18,21,06,03,09,24,15,,,,,2.5,1.6,1.9*3E

If you don’t see anything in the serial monitor, make sure the UART-select jumper is in the correct position. Also double check that the green “power” LED is at least light up. If it’s not, the module may not be receiving power. Don’t forget place the external antenna outside the window of your room!

NMEA strings are the standard message format produced by almost all GPS receivers. They can relay all sorts of information including the time, latitude, longitude, altitude, and number of satellites visible, but unless you’re an incredibly fast parser, these sentences will mostly mean nothing. Fortunately, the Arduino can read those strings, parse them for you, and give you more human-readable pieces of data.

Tags:

Book type: