Create a gist now

Instantly share code, notes, and snippets.

MultiNav FeatherWing Example Program for Feather 32U4
// Example Program for MultiNav FeatherWing
// For Adafruit Feather 32U4
// By: Dan Watson
// 1/25/2016
// This program makes use of the TinyGPS++ library to receive the GPS data from the U-Blox
// module, as well as the Sparkfun MPU-6050 library to interact with the MPU-9250 9DOF.
// TinyGPS++ Download:
// Sparkfun MPU-6050 Download:
// Credit is given to both Arduiniana and Sparkfun for the use of their excellent libraries, and portions
// of their example programs. Thank you!
// The built-in SoftwareSerial library is also used.
#include <TinyGPS++.h>
#include "Wire.h"
#include "I2Cdev.h"
#include "MPU6050.h"
#include "SoftwareSerial.h"
// Pinout:
// * I2C: SDA and SCL pins in the same location on all Feather boards.
// * UART: For 32U4, connect Option A on JP3 and use SoftwareSerial (D11 Rx, D10 Tx)
// * Interrupts:
// MPU-9250 goes to D5. Connect JP1 to use.
// GPS Pulse-per-second goes to D6. Connect JP2 to use.
// HOWEVER, neither pin is usable as a hardware interrupt on 32U4
// You could check their levels with a while() loop if you really need
// to, but that is not a true interrupt.
// These are the I/O defines for Feather 32U4
#define ledPin 13
#define rxPin 11
#define txPin 10
volatile bool periodic = false;
int16_t ax, ay, az;
int16_t gx, gy, gz;
int16_t mx, my, mz;
TinyGPSPlus gps;
SoftwareSerial SerialGPS(rxPin, txPin);
MPU6050 accelgyro;
void setup()
Serial.println("MultiNav FeatherWing Test Program!");
Serial.println("Ensure a GPS antenna is connected and has a clear view of the sky");
Serial.println("Initializing I2C for MPIU-9250");
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
pinMode(ledPin, OUTPUT);
void loop()
// Data strings also arrive from the GPS once per second
// When TinyGPS gets fresh data, print out some example strings
if (gps.time.isUpdated())
if (gps.time.isValid())
// Update 9DOF data
accelgyro.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);
char buffer[24];
sprintf(buffer, "UTC: %02d/%02d/%04d %02d:%02d:%02d",,,, gps.time.hour(), gps.time.minute(), gps.time.second());
for (int i = 0; i < sizeof(buffer); i++)
} else {
Serial.println("UTC Error: Time Not Valid");
if (gps.location.isValid())
Serial.print("Lat ");
Serial.print(, 6);
Serial.print(", Lng ");
Serial.println(gps.location.lng(), 6);
Serial.print("Altitude ");
} else {
Serial.println("Position Error: Not Valid");
if (gps.satellites.isValid())
Serial.print("SVs In Use: ");
if (gps.hdop.isValid())
Serial.print("HDOP: ");
Serial.println((float) gps.hdop.value() / 100);
Serial.print(ax); Serial.print("\t");
Serial.print(ay); Serial.print("\t");
Serial.print(az); Serial.print("\t");
Serial.print(gx); Serial.print("\t");
Serial.print(gy); Serial.print("\t");
Serial.print(gz); Serial.print("\t");
Serial.print(mx); Serial.print("\t");
Serial.print(my); Serial.print("\t");
// Ingest new serial strings from the GPS into TinyGPS as they arrive
while(SerialGPS.available() > 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment