GPS parsing with PA1010D and M0

Updated on 23 September 2022
dev board RobotDyn M0 Mini
chip PA1010D
sensor GPS
features UART Google Maps
This tutorial is more than 1 year old. If the steps below do not work, then please check the latest versions and the documentations of the individual tools used.

Before starting

Dependancies

Ensure the following dependancies are downloaded and available:

Pre-requisites

Try these simpler or similar examples:

Buy the components

Code

Download code gps-pa1010d-m0-parsing.ino
#include <Adafruit_GPS.h>
#define GPSSerial Serial1

Adafruit_GPS GPS(&GPSSerial);

#define GPSECHO false

uint32_t timer = millis();

void setup() {
  while (!Serial) {}
  SerialUSB.begin(115200);
  SerialUSB.println("Adafruit GPS library basic test!");

  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
  GPS.sendCommand(PGCMD_ANTENNA);

  delay(1000);

  GPSSerial.println(PMTK_Q_RELEASE);
}

void loop() {
  char c = GPS.read();

  if (GPS.newNMEAreceived()) {
    if (!GPS.parse(GPS.lastNMEA())) {
      return;
    }
  }

  if (millis() - timer > 2000) {
    timer = millis();
    SerialUSB.print("\nTime: ");
    if (GPS.hour < 10) { SerialUSB.print('0'); }
    SerialUSB.print(GPS.hour, DEC); SerialUSB.print(':');
    if (GPS.minute < 10) { SerialUSB.print('0'); }
    SerialUSB.print(GPS.minute, DEC); SerialUSB.print(':');
    if (GPS.seconds < 10) { SerialUSB.print('0'); }
    SerialUSB.print(GPS.seconds, DEC); SerialUSB.print('.');
    if (GPS.milliseconds < 10) {
      SerialUSB.print("00");
    } else if (GPS.milliseconds > 9 && GPS.milliseconds < 100) {
      SerialUSB.print("0");
    }
    SerialUSB.println(GPS.milliseconds);
    SerialUSB.print("Date: ");
    SerialUSB.print(GPS.day, DEC); SerialUSB.print('/');
    SerialUSB.print(GPS.month, DEC); SerialUSB.print("/20");
    SerialUSB.println(GPS.year, DEC);
    SerialUSB.print("Fix: ");
    SerialUSB.print((int)GPS.fix);
    SerialUSB.print(" quality: "); SerialUSB.println((int)GPS.fixquality);
    SerialUSB.print("Time [s] since last fix: ");
    SerialUSB.println(GPS.secondsSinceFix(), 3);
    SerialUSB.print("    since last GPS time: ");
    SerialUSB.println(GPS.secondsSinceTime(), 3);
    SerialUSB.print("    since last GPS date: ");
    SerialUSB.println(GPS.secondsSinceDate(), 3);
    if (GPS.fix) {
      SerialUSB.print("Location: ");
      SerialUSB.print(GPS.latitude, 4); SerialUSB.print(GPS.lat);
      SerialUSB.print(", ");
      SerialUSB.print(GPS.longitude, 4); SerialUSB.println(GPS.lon);
      SerialUSB.print("Speed (knots): "); SerialUSB.println(GPS.speed);
      SerialUSB.print("Angle: "); SerialUSB.println(GPS.angle);
      SerialUSB.print("Altitude: "); SerialUSB.println(GPS.altitude);
      SerialUSB.print("Satellites: "); SerialUSB.println((int)GPS.satellites);
    }
  }
}

Makefile

BOARD?=arduino:samd:mzero_bl
PORT := $(shell ls /dev/cu.usbmodem*)

.PHONY: default lint all flash clean

default: lint all flash clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright,-readability/casting *.ino

all:
	arduino-cli compile --fqbn $(BOARD) ./

flash:
	arduino-cli upload -p $(PORT) --fqbn $(BOARD) ./

clean:
	rm -f .*.bin
	rm -f .*.elf
	rm -f .*.hex

Prototype

A photo of the actual setup.

GPS parsing with PA1010D and M0 prototype

Serial console

Serial output from the firmware.

GPS parsing with PA1010D and M0 serial console

Description

Use GPS module PA1010D with Arduino M0 (SAMD21G) to display parsed GPS data with latitude and longitude in degrees.

Using Google maps to view lat,long

  1. Right click the spot on Google maps
  2. Click “What’s here?”
  3. Click the lat,long in the card at the bottom
  4. View the lat,long data in degrees and decimal at the left sidebar

References

Watch