Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

#include <Wire.h> //Needed for I2C to GPS

#include "SparkFun_Ublox_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_Ublox_GPS
SFE_UBLOX_GPS myGPS;

unsigned long lastGPSSend = 0;

void setup()
{
Serial.begin(9600); // Serial debug output over USB visible from Arduino IDE
Serial1.begin(9600); // NMEA serial UART output port to SPP bluetooth device such as HC-06

Wire.begin();

if (myGPS.begin() == false)
{
Serial.println(F("Error initializing GPS"));
while (1);
}

myGPS.setI2COutput(COM_TYPE_NMEA | COM_TYPE_UBX);
myGPS.setCFG_MSG(UBX_CLASS_NAV, UBX_NAV_PVT, 0); //Some of the other examples enable this message
myGPS.setCFG_MSG(UBX_CLASS_NMEA, UBX_NMEA_GLL, 0); //Several of these are on by default on virgin ublox board
myGPS.setCFG_MSG(UBX_CLASS_NMEA, UBX_NMEA_GSA, 0);
myGPS.setCFG_MSG(UBX_CLASS_NMEA, UBX_NMEA_GSV, 0);
myGPS.setCFG_MSG(UBX_CLASS_NMEA, UBX_NMEA_RMC, 0);
myGPS.setCFG_MSG(UBX_CLASS_NMEA, UBX_NMEA_GGA, 1); //Only leaving GGA/VTG enabled at current navigation rate
myGPS.setCFG_MSG(UBX_CLASS_NMEA, UBX_NMEA_VTG, 1);

myGPS.setNMEAOutputPort(Serial1);
}

void loop()
{
if (millis() - lastGPSSend > 200){
myGPS.checkUblox(); //See if new data is available, NMEA message will be auto-forwarded out Serial1
lastGPSSend = millis();
}
}
14 changes: 14 additions & 0 deletions src/SparkFun_Ublox_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,20 @@ boolean SFE_UBLOX_GPS::setAutoPVT(boolean enable, boolean implicitUpdate, uint16
return ok;
}

boolean SFE_UBLOX_GPS::setCFG_MSG(uint8_t msgClass, uint8_t messageID, uint8_t rate, uint16_t maxWait)
{
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_MSG;
packetCfg.len = 3;
packetCfg.startingSpot = 0;
payloadCfg[0] = msgClass;
payloadCfg[1] = messageID;
payloadCfg[2] = rate;

bool ok = sendCommand(packetCfg, maxWait);
return ok;
}

//Add a new geofence using UBX-CFG-GEOFENCE
boolean SFE_UBLOX_GPS::addGeofence(int32_t latitude, int32_t longitude, uint32_t radius, byte confidence, byte pinPolarity, byte pin, uint16_t maxWait)
{
Expand Down
13 changes: 13 additions & 0 deletions src/SparkFun_Ublox_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const uint8_t UBX_CLASS_MGA = 0x13;
const uint8_t UBX_CLASS_LOG = 0x21;
const uint8_t UBX_CLASS_SEC = 0x27;
const uint8_t UBX_CLASS_HNR = 0x28;
const uint8_t UBX_CLASS_NMEA = 0xF0;

const uint8_t UBX_CFG_PRT = 0x00; //Used to configure port specifics
const uint8_t UBX_CFG_RST = 0x04; //Used to reset device
Expand All @@ -118,6 +119,17 @@ const uint8_t UBX_NAV_HPPOSLLH = 0x14; //Used for obtaining lat/long/alt in hig
const uint8_t UBX_NAV_SVIN = 0x3B; //Used for checking Survey In status
const uint8_t UBX_NAV_RELPOSNED = 0x3C; //Relative Positioning Information in NED frame

const uint8_t UBX_NMEA_GGA = 0x00;
const uint8_t UBX_NMEA_GLL = 0x01;
const uint8_t UBX_NMEA_GNS = 0x0D;
const uint8_t UBX_NMEA_GRS = 0x06;
const uint8_t UBX_NMEA_GSA = 0x02;
const uint8_t UBX_NMEA_GST = 0x07;
const uint8_t UBX_NMEA_GSV = 0x03;
const uint8_t UBX_NMEA_RMC = 0x04;
const uint8_t UBX_NMEA_VTG = 0x05;
const uint8_t UBX_NMEA_ZDA = 0x08;

const uint8_t UBX_MON_VER = 0x04; //Used for obtaining Protocol Version
const uint8_t UBX_MON_TXBUF = 0x08; //Used for query tx buffer size/state

Expand Down Expand Up @@ -258,6 +270,7 @@ class SFE_UBLOX_GPS
boolean waitForResponse(uint8_t requestedClass, uint8_t requestedID, uint16_t maxTime = 250); //Poll the module until and ack is received

boolean assumeAutoPVT(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and PVT is send cyclically already
boolean setCFG_MSG(uint8_t msgClass, uint8_t messageID, uint8_t rate, uint16_t maxWait = 250);
boolean setAutoPVT(boolean enabled, uint16_t maxWait = 250); //Enable/disable automatic PVT reports at the navigation frequency
boolean getPVT(uint16_t maxWait = 1000); //Query module for latest group of datums and load global vars: lat, long, alt, speed, SIV, accuracies, etc. If autoPVT is disabled, performs an explicit poll and waits, if enabled does not block. Retruns true if new PVT is available.
boolean setAutoPVT(boolean enabled, boolean implicitUpdate, uint16_t maxWait = 250); //Enable/disable automatic PVT reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update
Expand Down