Oak

🌳 An outdoor LoRa-GPS tracker with an E-Ink display 🔑

power 18650
wireless LoRa,
sensor GPS, E-Ink
mcu SAMD21G18
bom items 82
bom cost USD $78.93
vendors 6
completed July 2022

GPS fix with parsed lat-long

gps PA1010D UART TX RX fix medium

Display the parsed NMEA string information on the serial console after a successful GPS fix


Before starting

Dependancies

Adafruit GPS

Details

Ensure you have access to the open skies for a potential GPS fix.

When the serial console shows the latitude and longitude information, the PPS Red LED should also blink once per second.

Steps

  1. Ensure you have access to open skies for a GPS fix
  2. Plug in the Oak PCB to the computer
  3. (Option A) Ensure the PCB can be detected with ls -al /dev/cu.usbmodem and arduino-cli board list. Run make to compile and upload the code to the board. (Option A) Ensure the PCB can be detected with <code>ls -al /dev/cu.usbmodem</code> and <code>arduino-cli board list</code>. Run <code>make</code> to compile and upload the code to the board.
  4. (Option B) Ensure the board can be detected with Arduino IDE. Compile and upload the code to the board. (Option B) Ensure the board can be detected with Arduino IDE. Compile and upload the code to the board.
  5. Start the serial monitor

Serial console

Serial output from the firmware.

Schematic

Wire up the hardware accordingly

 setup

Code

Download code
#include <Adafruit_GPS.h>
#define GPSSerial Serial1

Adafruit_GPS GPS(&GPSSerial);

#define GPSECHO false
#define LEDPIN 2
#define GPSRST 3

int ledState = 0;

uint32_t timer = millis();

void setup() {
  SerialUSB.begin(9600);
  SerialUSB.println("Adafruit GPS library basic test!");

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

  pinMode(GPSRST, OUTPUT);
  digitalWrite(GPSRST, HIGH);

  delay(1000);

  // Initiate the LED pin as an output
  pinMode(LEDPIN, OUTPUT);
  digitalWrite(LEDPIN, ledState);
}

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);
    SerialUSB.print("Location: ");
    SerialUSB.print(GPS.latitude, 8);
    SerialUSB.print(GPS.lat);
    SerialUSB.print(", ");
    SerialUSB.print(GPS.longitude, 8);
    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);

    // LED Toggle
    ledState = !ledState;
    digitalWrite(LEDPIN, ledState);
  }
}

Makefile

BOARD?=hutscape:samd:oak
PORT := $(shell ls /dev/cu.usbmodem*)
BUILD=build

.PHONY: default lint all flash clean

default: lint all flash clean

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

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

flash:
	arduino-cli upload -p $(PORT) --fqbn $(BOARD) --input-dir $(BUILD) --verbose

clean:
	rm -r build

References

Photos

GPS fix with parsed lat-long Photo 1