GPS

Adafruit GPS Featherwing

  • 20 mA current draw during navigation
  • Internal patch antenna + u.FL connector for external active antenna
  • RTC with coin battery backup
  • $60/ea for GPS, ext antenna, RTC battery

 

AF GPS FeatherWing

AF GPS FeatherWing tutorial

AF GPS library

The 12 mm coin cell (CR1220) provides backup power to the GPS for it's settings and for the RTC.   The battery will last about 240 days under continual use (battery only used when no 3V power is provided to the GPS), otherwise it will last for years.   The GPS sets the internal RTC when it gets a fix and then as long as the battery is installed, you can read the date/time from the GPS using the library and you will get the correct time from the RTC (even without a proper GPS fix, the date/time will be correct).   The time zone is fixed on UTC.   The GPS module will not pass the year 2038 rollover test.   You cannot otherwise programmatically access the RTC.   Position Accuracy: 1.8 meters (5.9 ft).   Velocity Accuracy: 0.1 meters/s (0.22 mph)

Resources Used

  • 20 mA during navigation
  • Serial Tx & Rx lines on the attached microcontroller   (D9 & D10 on Boron/Argon; pins 0 & 1 on M0 Basic & M4 Express)

////////////////////////////////////////////////////////////////
// Adafruit GPS FeatherWing
// https://www.adafruit.com/product/3133
// https://learn.adafruit.com/adafruit-ultimate-gps-featherwing?view=all

#include 

// what's the name of the hardware serial port?
#define GPSSerial Serial1

// Connect to the GPS on the hardware port
Adafruit_GPS GPS(&GPSSerial);

// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
// Set to 'true' if you want to debug and listen to the raw GPS sentences
#define GPSECHO false

uint32_t timer = millis();

char isoDateTime[26];
////////////////////////////////////////////////////////////////


void setup() {
  //while (!Serial);  // uncomment to have the sketch wait until Serial is ready

  // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
  // also spit it out
  Serial.begin(115200);

  ////////////////////////////////////////////////////////////////
  // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
  GPS.begin(9600);
  // Turn on RMC (recommended minimum) and GGA (fix data) including altitude
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  // Set the update rate
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
  // Request updates on antenna status, comment out to keep quiet
  GPS.sendCommand(PGCMD_ANTENNA);
  delay(1000);
  // Ask for firmware version
  GPSSerial.println(PMTK_Q_RELEASE);
  ////////////////////////////////////////////////////////////////
} // setup()

void loop() {
  ////////////////////////////////////////////////////////////////
  // start AF GPS FeatherWing
  // In ideal conditions, the GPS module can get a fix in under 45 seconds
  // read data from the GPS in the 'main loop'
  char c = GPS.read();
  // if a sentence is received, we can check the checksum, parse it...
  if (GPS.newNMEAreceived()) {
    if (!GPS.parse(GPS.lastNMEA())) {
      // ERROR - failed to parse a GPS sentence.  
    } else {
      if (timer > millis()) timer = millis();
      // approximately every 2 seconds or so, print out the current stats
      if (millis() - timer > 2000) {
        timer = millis(); // reset the timer
        Serial.print("\nUTC DateTime: ");
        // 2020-02-05T08:50:05+00:00
        sprintf(isoDateTime, "%4d-%02d-%02dT%02d:%02d:%02d%+05d",
         GPS.year+2000, GPS.month, GPS.day, GPS.hour, GPS.minute, GPS.seconds, 0 );
        Serial.println(isoDateTime);  
        // GPS.fix = 1 if a GPS fix was successful.
        // GPS fixquality of 2 is good
        Serial.print("Fix: "); Serial.print((int)GPS.fix); Serial.print("; ");
        Serial.print(" quality: "); Serial.print((int)GPS.fixquality); ; Serial.print("; ");
        if (!GPS.fix) {
          Serial.println();
          Serial.println("NO GPS fix!");
        } else {
          Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
          // Hidden feature of the library: Adafruit_GPS.h
          Serial.print("Location: ");
          Serial.print(GPS.latitudeDegrees,5);
          Serial.print(", ");
          Serial.println(GPS.longitudeDegrees,5);
          
          Serial.print("Speed (knots): "); Serial.println(GPS.speed);
          Serial.print("Angle: "); Serial.println(GPS.angle);
          Serial.print("Altitude (meters): "); Serial.println(GPS.altitude);
        }
      }
    }
  } // if (GPS.newNMEAreceived())
  ////////////////////////////////////////////////////////////////
  
} // loop()

 

More AF FeatherWing products from Adafruit and from Particle

 


Do you need help developing or customizing a IoT product for your needs?   Send me an email requesting a free one hour phone / web share consultation.  

 

The information presented on this website is for the author's use only.   Use of this information by anyone other than the author is offered as guidelines and non-professional advice only.   No liability is assumed by the author or this web site.