Skip to content

Commit 64ba650

Browse files
authored
Merge pull request #49 from sparkfun/release_candidate
v2.0.8
2 parents 929a9ee + e3d9bc3 commit 64ba650

File tree

12 files changed

+637
-18
lines changed

12 files changed

+637
-18
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</tr>
1818
</table>
1919

20-
u-blox makes some incredible GNSS receivers covering everything from low-cost, highly configurable modules such as the SAM-M8Q all the way up to the surveyor grade ZED-F9P with precision of the diameter of a dime. This library focuses on configuration and control of u-blox devices over I<sup>2</sup>C (called DDC by u-blox) and Serial. The UBX protocol is supported over both I<sup>2</sup>C and serial, and is a much easier and lighterweight interface to a GNSS module. Stop polling messages and parsing NMEA data! Simply ask for the datums you need and receive an automatic callback when they arrive.
20+
u-blox makes some incredible GNSS receivers covering everything from low-cost, highly configurable modules such as the SAM-M8Q all the way up to the surveyor grade ZED-F9P with precision of the diameter of a dime. This library supports configuration and control of u-blox devices over I<sup>2</sup>C (called DDC by u-blox), Serial and - as of v2.0.8 (thank you @aberridg) - SPI too! The UBX protocol is a much easier and lighterweight interface to a GNSS module. Stop polling messages and parsing NMEA data! Simply ask for the datums you need and receive an automatic callback when they arrive.
2121

2222
This library can be installed via the Arduino Library manager. Search for **SparkFun u-blox GNSS**.
2323

@@ -53,6 +53,18 @@ Migrating to v2.0 is easy. There are two small changes all users will need to ma
5353

5454
If you are using the Dead Reckoning Sensor Fusion or High Dynamic Rate messages, you will need to make more small changes to your code. Please see the [dead reckoning examples](./examples/Dead_Reckoning) for more details. There is more detail available in [Theory.md](./Theory.md#migrating-your-code-to-v20) if you need it.
5555

56+
## SPI Support
57+
58+
In v2.0.8 we added support for SPI, based on a contribution by @aberridg. Thank you Andrew!
59+
60+
We have tested the SPI interface on as many platforms and modules as we could pull together. It works perfectly on most but not quite all combinations.
61+
For reasons we don't understand yet, the ZED-F9P and Teensy 3.2 don't seem to get along. But Teensy 3.2 and the ZOE-M8Q do play nicely together.
62+
If you notice a combination that does not seem to work, please raise an [issue](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/issues) and we will investigate.
63+
64+
The SPI examples have their [own folder](./examples/SPI).
65+
66+
Please check the module datasheets for details on what clock speeds and data rates each module supports. The maximum clock speed is typically 5.5MHz and the maximum transfer rate is typically 125kBytes/s.
67+
5668
## Max (400kHz) I<sup>2</sup>C Support
5769

5870
To achieve 400kHz I<sup>2</sup>C speed please be sure to remove all pull-ups on the I<sup>2</sup>C bus. Most, if not all, u-blox modules include internal pull ups on the I<sup>2</sup>C lines (sometimes called DDC in their manuals). Cut all I<sup>2</sup>C pull up jumpers and/or remove them from peripheral boards. Otherwise, various data glitches can occur. See issues [38](https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library/issues/38) and [40](https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library/issues/40) for more information. If possible, run the I<sup>2</sup>C bus at 100kHz.

examples/Example18_PowerSaveMode/Example18_PowerSaveMode.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,22 @@ void loop()
8585
if (myGNSS.powerSaveMode()) // Defaults to true
8686
Serial.println(F("Power Save Mode enabled."));
8787
else
88-
Serial.println(F("***!!! Power Save Mode FAILED !!!***"));
88+
Serial.println(F("*** Power Save Mode FAILED ***"));
8989
}
9090
else if (incoming == '2')
9191
{
9292
//Go to normal power mode (not power saving mode)
9393
if (myGNSS.powerSaveMode(false))
9494
Serial.println(F("Power Save Mode disabled."));
9595
else
96-
Serial.println(F("***!!! Power Save Disable FAILED !!!***"));
96+
Serial.println(F("*** Power Save Disable FAILED ***"));
9797
}
9898

9999
// Read and print the new low power mode
100100
uint8_t lowPowerMode = myGNSS.getPowerSaveMode();
101101
if (lowPowerMode == 255)
102102
{
103-
Serial.println(F("***!!! getPowerSaveMode FAILED !!!***"));
103+
Serial.println(F("*** getPowerSaveMode FAILED ***"));
104104
}
105105
else
106106
{

examples/Example19_DynamicModel/Example19_DynamicModel.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void setup()
6868

6969
if (myGNSS.setDynamicModel(DYN_MODEL_PORTABLE) == false) // Set the dynamic model to PORTABLE
7070
{
71-
Serial.println(F("***!!! Warning: setDynamicModel failed !!!***"));
71+
Serial.println(F("*** Warning: setDynamicModel failed ***"));
7272
}
7373
else
7474
{
@@ -79,7 +79,7 @@ void setup()
7979
uint8_t newDynamicModel = myGNSS.getDynamicModel();
8080
if (newDynamicModel == DYN_MODEL_UNKNOWN)
8181
{
82-
Serial.println(F("***!!! Warning: getDynamicModel failed !!!***"));
82+
Serial.println(F("*** Warning: getDynamicModel failed ***"));
8383
}
8484
else
8585
{

examples/Example1_BasicNMEARead/Example1_BasicNMEARead.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ void setup()
3939
while (1);
4040
}
4141

42+
myGNSS.setI2COutput(COM_TYPE_UBX | COM_TYPE_NMEA); //Set the I2C port to output both NMEA and UBX messages
43+
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
44+
4245
//This will pipe all NMEA sentences to the serial port so we can see them
4346
myGNSS.setNMEAOutputPort(Serial);
4447
}

examples/Example24_GetUnixEpochAndMicros/Example24_GetUnixEpochAndMicros.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ void loop()
9191
Serial.print(myGNSS.getSecond());
9292

9393
Serial.print(" Time is ");
94+
if (myGNSS.getTimeFullyResolved() == false)
95+
{
96+
Serial.print("not fully resolved but ");
97+
} else {
98+
Serial.print("fully resolved and ");
99+
}
94100
if (myGNSS.getTimeValid() == false)
95101
{
96102
Serial.print("not ");

examples/Example2_NMEAParsing/Example2_NMEAParsing.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ void setup()
4646
while (1);
4747
}
4848

49+
myGNSS.setI2COutput(COM_TYPE_UBX | COM_TYPE_NMEA); //Set the I2C port to output both NMEA and UBX messages
50+
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
51+
4952
myGNSS.setProcessNMEAMask(SFE_UBLOX_FILTER_NMEA_ALL); // Make sure the library is passing all NMEA messages to processNMEA
5053

5154
myGNSS.setProcessNMEAMask(SFE_UBLOX_FILTER_NMEA_GGA); // Or, we can be kind to MicroNMEA and _only_ pass the GGA messages to it
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
Reading lat and long via UBX binary commands over SPI
3+
By: Andrew Berridge
4+
Date: 27th June 2021
5+
License: MIT. See license file for more information but you can
6+
basically do whatever you want with this code.
7+
8+
This example shows how to query a u-blox module for its lat/long/altitude over SPI. We also
9+
turn off the NMEA output on the SPI port. This decreases the amount of SPI traffic
10+
dramatically.
11+
12+
Note: Long/lat are large numbers because they are * 10^7. To convert lat/long
13+
to something google maps understands simply divide the numbers by 10,000,000. We
14+
do this so that we don't have to use floating point numbers.
15+
16+
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
17+
18+
Feel like supporting open source hardware?
19+
Buy a board from SparkFun!
20+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
21+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
22+
NEO-M8U: https://www.sparkfun.com/products/16329
23+
NEO-M9N: https://www.sparkfun.com/products/17285
24+
25+
Hardware Connections:
26+
You need to connect the SPI pins from your microcontroller to the specific pins on your SparkFun product.
27+
Connections will vary based on your microcontroller, but for reference please refer to this tutorial on SPI:
28+
https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/all
29+
30+
Most new boards now use the terms:
31+
CS - Chip Select
32+
COPI - Controller Out, Peripheral In
33+
CIPO - Controller in, Peripheral Out
34+
SCK - Serial Clock
35+
36+
You can choose any pin for Chip Select, but the others are likely either defined by the library you are using
37+
(see here for the standard Arduino one: https://www.arduino.cc/en/reference/SPI) or the microcontroller. The
38+
ESP32 has two standard, selectable SPI ports, for example.
39+
40+
To enable SPI communication, you will need to solder the DSEL/SPI jumper closed on your u-blox board.
41+
42+
IMPORTANT: there have been reports that some u-blox devices do not respond to the UBX protocol over SPI
43+
with the factory settings. You may find you need to connect to the device via USB and u-center and set
44+
the incoming protocol to UBX only. Make sure you disable all other protocols as inputs if you can't
45+
get things to work! Hopefully this is just a bug in the u-blox firmware that will be fixed soon ;-)
46+
47+
*/
48+
49+
#include <SPI.h> //Needed for SPI to GNSS
50+
51+
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
52+
SFE_UBLOX_GNSS myGNSS;
53+
54+
// #########################################
55+
56+
// Instantiate an instance of the SPI class.
57+
// Your configuration may be different, depending on the microcontroller you are using!
58+
59+
#define spiPort SPI // This is the SPI port on standard Ardino boards. Comment this line if you want to use a different port.
60+
61+
//SPIClass spiPort (HSPI); // This is the default SPI interface on some ESP32 boards. Uncomment this line if you are using ESP32.
62+
63+
// #########################################
64+
65+
const uint8_t csPin = 10; // On ATmega328 boards, SPI Chip Select is usually pin 10. Change this to match your board.
66+
67+
// #########################################
68+
69+
long lastTime = 0; //Simple local timer. Limits amount of SPI traffic to u-blox module.
70+
71+
void setup()
72+
{
73+
Serial.begin(115200);
74+
while (!Serial); //Wait for user to open terminal
75+
Serial.println(F("SparkFun u-blox Example"));
76+
77+
spiPort.begin(); // begin the SPI port
78+
79+
//myGNSS.enableDebugging(); // Uncomment this line to see helpful debug messages on Serial
80+
81+
// Connect to the u-blox module using SPI port, csPin and speed setting
82+
// ublox devices generally work up to 5MHz. We'll use 4MHz for this example:
83+
if (myGNSS.begin(spiPort, csPin, 4000000) == false)
84+
{
85+
Serial.println(F("u-blox GNSS not detected on SPI bus. Please check wiring. Freezing."));
86+
while (1);
87+
}
88+
89+
//myGNSS.factoryDefault(); delay(5000); // Uncomment this line to reset the module back to its factory defaults
90+
91+
myGNSS.setPortOutput(COM_PORT_SPI, COM_TYPE_UBX); //Set the SPI port to output UBX only (turn off NMEA noise)
92+
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
93+
}
94+
95+
void loop()
96+
{
97+
//Query module only every second. Doing it more often will just cause SPI traffic.
98+
//The module only responds when a new position is available
99+
if (millis() - lastTime > 1000)
100+
{
101+
lastTime = millis(); //Update the timer
102+
103+
long latitude = myGNSS.getLatitude();
104+
Serial.print(F("Lat: "));
105+
Serial.print(latitude);
106+
107+
long longitude = myGNSS.getLongitude();
108+
Serial.print(F(" Long: "));
109+
Serial.print(longitude);
110+
Serial.print(F(" (degrees * 10^-7)"));
111+
112+
long altitude = myGNSS.getAltitude();
113+
Serial.print(F(" Alt: "));
114+
Serial.print(altitude);
115+
Serial.print(F(" (mm)"));
116+
117+
byte SIV = myGNSS.getSIV();
118+
Serial.print(F(" SIV: "));
119+
Serial.print(SIV);
120+
121+
Serial.println();
122+
}
123+
}

0 commit comments

Comments
 (0)