Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 8be456c

Browse files
authored
Merge pull request #134 from sparkfun/Expand-getVal-setVal
Expand getVal/setVal method
2 parents 50086e4 + 6239fc2 commit 8be456c

File tree

10 files changed

+790
-122
lines changed

10 files changed

+790
-122
lines changed

examples/ZED-F9P/Example6_GetVal/Example6_GetVal.ino

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
2-
Send UBX binary commands to enable RTCM sentences on Ublox ZED-F9P module
2+
Get a device's I2C address using advanced getVal method
33
By: Nathan Seidle
44
SparkFun Electronics
55
Date: January 9th, 2019
66
License: MIT. See license file for more information but you can
77
basically do whatever you want with this code.
88
9-
Ublox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
9+
u-blox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
1010
UBX-CFG commands are deprecated; they still work, they just recommend using VALSET, VALGET, and VALDEL
1111
commands instead. This example shows how to use this new command structure.
1212
@@ -32,27 +32,29 @@ long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox m
3232
void setup()
3333
{
3434
Serial.begin(115200);
35-
while (!Serial); //Wait for user to open terminal
36-
Serial.println("Ublox getVal example");
35+
while (!Serial)
36+
; //Wait for user to open terminal
37+
Serial.println("u-blox getVal example");
3738

3839
Wire.begin();
3940
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
4041

4142
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
4243
{
43-
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
44-
while (1);
44+
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
45+
while (1)
46+
;
4547
}
4648

4749
myGPS.enableDebugging(); //Enable debug messages over Serial (default)
4850
//myGPS.enableDebugging(SerialUSB); //Enable debug messages over Serial USB
4951

50-
uint8_t currentI2Caddress = myGPS.getVal8(0x20510001);
52+
uint8_t currentI2Caddress = myGPS.getVal8(UBLOX_CFG_I2C_ADDRESS);
5153
Serial.print("Current I2C address (should be 0x42): 0x");
5254
Serial.println(currentI2Caddress >> 1, HEX); //Ublox module returns a shifted 8-bit address. Make it 7-bit unshifted.
5355

54-
while(1);
55-
56+
while (1)
57+
;
5658
}
5759

5860
void loop()
@@ -83,4 +85,4 @@ void loop()
8385

8486
Serial.println();
8587
}
86-
}
88+
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
2-
Send UBX binary commands to enable RTCM sentences on Ublox ZED-F9P module
2+
Send UBX binary commands to enable RTCM sentences on u-blox ZED-F9P module
33
By: Nathan Seidle
44
SparkFun Electronics
55
Date: January 9th, 2019
66
License: MIT. See license file for more information but you can
77
basically do whatever you want with this code.
88
9-
Ublox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
9+
u-blox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
1010
UBX-CFG commands are deprecated; they still work, they just recommend using VALSET, VALGET, and VALDEL
1111
commands instead. This example shows how to use this new command structure.
1212
@@ -27,49 +27,50 @@
2727
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
2828
SFE_UBLOX_GPS myGPS;
2929

30-
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.
30+
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module.
3131

3232
void setup()
3333
{
3434
Serial.begin(115200);
35-
while (!Serial); //Wait for user to open terminal
36-
Serial.println("Ublox getVal example");
35+
while (!Serial)
36+
; //Wait for user to open terminal
37+
Serial.println("u-blox getVal example");
3738

3839
Wire.begin();
3940
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
4041

41-
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
42+
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
4243
{
43-
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
44-
while (1);
44+
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
45+
while (1)
46+
;
4547
}
4648

4749
myGPS.enableDebugging(); //Enable debug messages over Serial (default)
4850
//myGPS.enableDebugging(SerialUSB); //Enable debug messages over Serial USB
4951

5052
bool setValueSuccess;
5153

52-
//These key values are hard coded. You can obtain them from the ZED-F9P interface description doc
54+
//These key values are hard coded and defined in u-blox_config_keys.h.
55+
//You can obtain them from the ZED-F9P interface description doc
5356
//or from u-center's Messages->CFG->VALSET window. Keys must be 32-bit.
54-
//setValueSuccess = myGPS.setVal(0x10930006, 0); //Enable high precision NMEA
55-
setValueSuccess = myGPS.setVal(0x30210001, 100); //Set measurement rate to 100ms (10Hz update rate)
56-
//setValueSuccess = myGPS.setVal(0x30210001, 1000); //Set measurement rate to 1000ms (1Hz update rate)
57+
//setValueSuccess = myGPS.setVal(UBLOX_CFG_NMEA_HIGHPREC, 0); //Enable high precision NMEA
58+
setValueSuccess = myGPS.setVal(UBLOX_CFG_RATE_MEAS, 100); //Set measurement rate to 100ms (10Hz update rate)
59+
//setValueSuccess = myGPS.setVal(UBLOX_CFG_RATE_MEAS, 1000); //Set measurement rate to 1000ms (1Hz update rate)
5760

5861
//Below is the original way we enabled the RTCM message on the I2C port. After that, we show how to do the same
5962
//but with setVal().
6063
//Original: myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second
6164
//setValueSuccess = myGPS.setVal(0x209102bd, 1); //Set output rate of msg 1005 over the I2C port to once per second
6265

63-
if(setValueSuccess == true)
66+
if (setValueSuccess == true)
6467
{
6568
Serial.println("Value was successfully set");
6669
}
6770
else
6871
Serial.println("Value set failed");
69-
7072
}
7173

7274
void loop()
7375
{
74-
7576
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
Configuring port settings using the newer getVal/setVal methods
3+
By: Nathan Seidle
4+
SparkFun Electronics
5+
Date: October 23rd, 2020
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
This example shows how to query a u-blox module for its UART1 settings and
10+
then change them if the settings aren't what we want.
11+
12+
Note: getVal/setVal/delVal are only support in u-blox protocol versions 27 and higher.
13+
14+
Feel like supporting open source hardware?
15+
Buy a board from SparkFun!
16+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
17+
18+
Hardware Connections:
19+
Plug a Qwiic cable into the GPS and a RedBoard
20+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
21+
Open the serial monitor at 115200 baud to see the output
22+
*/
23+
24+
#include <Wire.h> //Needed for I2C to GPS
25+
26+
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
27+
SFE_UBLOX_GPS myGPS;
28+
29+
void setup()
30+
{
31+
Serial.begin(115200);
32+
while (!Serial)
33+
; //Wait for user to open terminal
34+
Serial.println("SparkFun u-blox Example");
35+
36+
Wire.begin();
37+
38+
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
39+
{
40+
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
41+
while (1)
42+
;
43+
}
44+
45+
bool response = true;
46+
47+
//Read the settings from RAM (what the module is running right now, not BBR, Flash, or default)
48+
uint8_t currentUART1Setting_ubx = myGPS.getVal8(UBLOX_CFG_UART1INPROT_UBX);
49+
uint8_t currentUART1Setting_nmea = myGPS.getVal8(UBLOX_CFG_UART1INPROT_NMEA);
50+
uint8_t currentUART1Setting_rtcm3 = myGPS.getVal8(UBLOX_CFG_UART1INPROT_RTCM3X);
51+
52+
Serial.print("currentUART1Setting_ubx: ");
53+
Serial.println(currentUART1Setting_ubx);
54+
Serial.print("currentUART1Setting_nmea: ");
55+
Serial.println(currentUART1Setting_nmea);
56+
Serial.print("currentUART1Setting_rtcm3: ");
57+
Serial.println(currentUART1Setting_rtcm3);
58+
59+
//Check if NMEA and RTCM are enabled for UART1
60+
if (currentUART1Setting_ubx == 0 || currentUART1Setting_nmea == 0)
61+
{
62+
Serial.println("Updating UART1 configuration");
63+
64+
//setVal sets the values for RAM, BBR, and Flash automatically so no .saveConfiguration() is needed
65+
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_UBX, 1); //Enable UBX on UART1 Input
66+
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_NMEA, 1); //Enable NMEA on UART1 Input
67+
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_RTCM3X, 0); //Disable RTCM on UART1 Input
68+
69+
if (response == false)
70+
Serial.println("SetVal failed");
71+
else
72+
Serial.println("SetVal succeeded");
73+
}
74+
else
75+
Serial.println("No port change needed");
76+
77+
//Change speed of UART2
78+
uint32_t currentUART2Baud = myGPS.getVal32(UBLOX_CFG_UART2_BAUDRATE);
79+
Serial.print("currentUART2Baud: ");
80+
Serial.println(currentUART2Baud);
81+
82+
if (currentUART2Baud != 57600)
83+
{
84+
response &= myGPS.setVal32(UBLOX_CFG_UART2_BAUDRATE, 57600);
85+
if (response == false)
86+
Serial.println("SetVal failed");
87+
else
88+
Serial.println("SetVal succeeded");
89+
}
90+
else
91+
Serial.println("No baud change needed");
92+
93+
Serial.println("Done");
94+
}
95+
96+
void loop()
97+
{
98+
}

examples/ZED-F9P/Example10_multiSetVal/Example10_multiSetVal.ino renamed to examples/ZED-F9P/Example9_multiSetVal/Example9_multiSetVal.ino

+20-19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
2-
Send UBX binary commands to enable RTCM sentences on Ublox ZED-F9P module
2+
Send UBX binary commands to enable RTCM sentences on u-blox ZED-F9P module
33
Based on Example7 By: Nathan Seidle
44
SparkFun Electronics
55
Updated by Paul Clark to demonstrate setVal8/16/32, newCfgValset8/16/32, addCfgValset8/16/32 and sendCfgValset8/16/32
66
Date: July 1st, 2019
77
License: MIT. See license file for more information but you can
88
basically do whatever you want with this code.
99
10-
Ublox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
10+
u-blox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
1111
UBX-CFG commands are deprecated; they still work, they just recommend using VALSET, VALGET, and VALDEL
1212
commands instead. This example shows how to use this new command structure.
1313
@@ -31,16 +31,18 @@ SFE_UBLOX_GPS myGPS;
3131
void setup()
3232
{
3333
Serial.begin(115200);
34-
while (!Serial); //Wait for user to open terminal
35-
Serial.println("Ublox multi setVal example");
34+
while (!Serial)
35+
; //Wait for user to open terminal
36+
Serial.println("u-blox multi setVal example");
3637

3738
Wire.begin();
3839
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
3940

40-
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
41+
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
4142
{
42-
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
43-
while (1);
43+
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
44+
while (1)
45+
;
4446
}
4547

4648
myGPS.enableDebugging(); //Enable debug messages over Serial (default)
@@ -55,25 +57,25 @@ void setup()
5557
//U2, I2, E2 and X2 values are 16-bit
5658
//U4, I4, R4, E4, X4 values are 32-bit
5759

58-
setValueSuccess &= myGPS.setVal8(0x10930006, 0); //Enable high precision NMEA (value is 8-bit (L / U1))
59-
//setValueSuccess &= myGPS.setVal16(0x30210001, 200); //Set measurement rate to 100ms (10Hz update rate) (value is 16-bit (U2))
60-
//setValueSuccess &= myGPS.setVal16(0x30210001, 200, 1); //Set rate setting in RAM instead of BBR
61-
setValueSuccess &= myGPS.setVal16(0x30210001, 1000); //Set measurement rate to 1000ms (1Hz update rate) (value is 16-bit (U2))
60+
setValueSuccess &= myGPS.setVal8(UBLOX_CFG_NMEA_HIGHPREC, 0); //Enable high precision NMEA (value is 8-bit (L / U1))
61+
//setValueSuccess &= myGPS.setVal16(UBLOX_CFG_RATE_MEAS, 200); //Set measurement rate to 100ms (10Hz update rate) (value is 16-bit (U2))
62+
//setValueSuccess &= myGPS.setVal16(UBLOX_CFG_RATE_MEAS, 200, 1); //Set rate setting in RAM instead of BBR
63+
setValueSuccess &= myGPS.setVal16(UBLOX_CFG_RATE_MEAS, 1000); //Set measurement rate to 1000ms (1Hz update rate) (value is 16-bit (U2))
6264

6365
//Below is the original way we enabled a single RTCM message on the I2C port. After that, we show how to do the same
6466
//but with multiple messages all in one go using newCfgValset, addCfgValset and sendCfgValset.
6567
//Original: myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second
6668

6769
//Begin with newCfgValset8/16/32
68-
setValueSuccess &= myGPS.newCfgValset8(0x209102bd, 1); //Set output rate of msg 1005 over the I2C port to once per measurement (value is 8-bit (U1))
69-
//setValueSuccess &= myGPS.newCfgValset8(0x209102bd, 1, 7); //Set this and the following settings into Flash/RAM/BBR instead of BBR
70+
setValueSuccess &= myGPS.newCfgValset8(CFG_MSGOUT_RTCM_3X_TYPE1005_I2C, 1); //Set output rate of msg 1005 over the I2C port to once per measurement (value is 8-bit (U1))
71+
//setValueSuccess &= myGPS.newCfgValset8(CFG_MSGOUT_RTCM_3X_TYPE1005_I2C, 1, 7); //Set this and the following settings into Flash/RAM/BBR instead of BBR
7072
//Add extra keyIDs and values using addCfgValset8/16/32
71-
setValueSuccess &= myGPS.addCfgValset8(0x209102cc, 1); //Set output rate of msg 1077 over the I2C port to once per measurement (value is 8-bit (U1))
72-
setValueSuccess &= myGPS.addCfgValset8(0x209102d1, 1); //Set output rate of msg 1087 over the I2C port to once per measurement (value is 8-bit (U1))
73-
setValueSuccess &= myGPS.addCfgValset8(0x209102d6, 1); //Set output rate of msg 1127 over the I2C port to once per measurement (value is 8-bit (U1))
74-
setValueSuccess &= myGPS.addCfgValset8(0x20910318, 1); //Set output rate of msg 1097 over the I2C port to once per measurement (value is 8-bit (U1))
73+
setValueSuccess &= myGPS.addCfgValset8(CFG_MSGOUT_RTCM_3X_TYPE1077_I2C, 1); //Set output rate of msg 1077 over the I2C port to once per measurement (value is 8-bit (U1))
74+
setValueSuccess &= myGPS.addCfgValset8(CFG_MSGOUT_RTCM_3X_TYPE1087_I2C, 1); //Set output rate of msg 1087 over the I2C port to once per measurement (value is 8-bit (U1))
75+
setValueSuccess &= myGPS.addCfgValset8(CFG_MSGOUT_RTCM_3X_TYPE1127_I2C, 1); //Set output rate of msg 1127 over the I2C port to once per measurement (value is 8-bit (U1))
76+
setValueSuccess &= myGPS.addCfgValset8(CFG_MSGOUT_RTCM_3X_TYPE1097_I2C, 1); //Set output rate of msg 1097 over the I2C port to once per measurement (value is 8-bit (U1))
7577
// Add the final value and send the packet using sendCfgValset8/16/32
76-
setValueSuccess &= myGPS.sendCfgValset8(0x20910303, 10); //Set output rate of msg 1230 over the I2C port to once every 10 measurements (value is 8-bit (U1))
78+
setValueSuccess &= myGPS.sendCfgValset8(CFG_MSGOUT_RTCM_3X_TYPE1230_I2C, 10); //Set output rate of msg 1230 over the I2C port to once every 10 measurements (value is 8-bit (U1))
7779

7880
if (setValueSuccess == true)
7981
{
@@ -85,5 +87,4 @@ void setup()
8587

8688
void loop()
8789
{
88-
8990
}

keywords.txt

+3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ setUART2Output KEYWORD2
6464
setUSBOutput KEYWORD2
6565
setSPIOutput KEYWORD2
6666

67+
getVal KEYWORD2
6768
getVal8 KEYWORD2
69+
getVal16 KEYWORD2
70+
getVal32 KEYWORD2
6871
setVal KEYWORD2
6972
setVal8 KEYWORD2
7073
setVal16 KEYWORD2

0 commit comments

Comments
 (0)