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

Expand getVal/setVal method #134

Merged
merged 10 commits into from
Oct 26, 2020
22 changes: 12 additions & 10 deletions examples/ZED-F9P/Example6_GetVal/Example6_GetVal.ino
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
Send UBX binary commands to enable RTCM sentences on Ublox ZED-F9P module
Get a device's I2C address using advanced getVal method
By: Nathan Seidle
SparkFun Electronics
Date: January 9th, 2019
License: MIT. See license file for more information but you can
basically do whatever you want with this code.

Ublox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
u-blox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
UBX-CFG commands are deprecated; they still work, they just recommend using VALSET, VALGET, and VALDEL
commands instead. This example shows how to use this new command structure.

Expand All @@ -32,27 +32,29 @@ long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox m
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("Ublox getVal example");
while (!Serial)
; //Wait for user to open terminal
Serial.println("u-blox getVal example");

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

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

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

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

while(1);

while (1)
;
}

void loop()
Expand Down Expand Up @@ -83,4 +85,4 @@ void loop()

Serial.println();
}
}
}
31 changes: 16 additions & 15 deletions examples/ZED-F9P/Example7_SetVal/Example7_SetVal.ino
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
Send UBX binary commands to enable RTCM sentences on Ublox ZED-F9P module
Send UBX binary commands to enable RTCM sentences on u-blox ZED-F9P module
By: Nathan Seidle
SparkFun Electronics
Date: January 9th, 2019
License: MIT. See license file for more information but you can
basically do whatever you want with this code.

Ublox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
u-blox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
UBX-CFG commands are deprecated; they still work, they just recommend using VALSET, VALGET, and VALDEL
commands instead. This example shows how to use this new command structure.

Expand All @@ -27,49 +27,50 @@
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
SFE_UBLOX_GPS myGPS;

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

void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("Ublox getVal example");
while (!Serial)
; //Wait for user to open terminal
Serial.println("u-blox getVal example");

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

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

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

bool setValueSuccess;

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

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

if(setValueSuccess == true)
if (setValueSuccess == true)
{
Serial.println("Value was successfully set");
}
else
Serial.println("Value set failed");

}

void loop()
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
Configuring port settings using the newer getVal/setVal methods
By: Nathan Seidle
SparkFun Electronics
Date: October 23rd, 2020
License: MIT. See license file for more information but you can
basically do whatever you want with this code.

This example shows how to query a u-blox module for its UART1 settings and
then change them if the settings aren't what we want.

Note: getVal/setVal/delVal are only support in u-blox protocol versions 27 and higher.

Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136

Hardware Connections:
Plug a Qwiic cable into the GPS and a RedBoard
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/

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

#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
SFE_UBLOX_GPS myGPS;

void setup()
{
Serial.begin(115200);
while (!Serial)
; //Wait for user to open terminal
Serial.println("SparkFun u-blox Example");

Wire.begin();

if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
{
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1)
;
}

bool response = true;

//Read the settings from RAM (what the module is running right now, not BBR, Flash, or default)
uint8_t currentUART1Setting_ubx = myGPS.getVal8(UBLOX_CFG_UART1INPROT_UBX);
uint8_t currentUART1Setting_nmea = myGPS.getVal8(UBLOX_CFG_UART1INPROT_NMEA);
uint8_t currentUART1Setting_rtcm3 = myGPS.getVal8(UBLOX_CFG_UART1INPROT_RTCM3X);

Serial.print("currentUART1Setting_ubx: ");
Serial.println(currentUART1Setting_ubx);
Serial.print("currentUART1Setting_nmea: ");
Serial.println(currentUART1Setting_nmea);
Serial.print("currentUART1Setting_rtcm3: ");
Serial.println(currentUART1Setting_rtcm3);

//Check if NMEA and RTCM are enabled for UART1
if (currentUART1Setting_ubx == 0 || currentUART1Setting_nmea == 0)
{
Serial.println("Updating UART1 configuration");

//setVal sets the values for RAM, BBR, and Flash automatically so no .saveConfiguration() is needed
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_UBX, 1); //Enable UBX on UART1 Input
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_NMEA, 1); //Enable NMEA on UART1 Input
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_RTCM3X, 0); //Disable RTCM on UART1 Input

if (response == false)
Serial.println("SetVal failed");
else
Serial.println("SetVal succeeded");
}
else
Serial.println("No port change needed");

//Change speed of UART2
uint32_t currentUART2Baud = myGPS.getVal32(UBLOX_CFG_UART2_BAUDRATE);
Serial.print("currentUART2Baud: ");
Serial.println(currentUART2Baud);

if (currentUART2Baud != 57600)
{
response &= myGPS.setVal32(UBLOX_CFG_UART2_BAUDRATE, 57600);
if (response == false)
Serial.println("SetVal failed");
else
Serial.println("SetVal succeeded");
}
else
Serial.println("No baud change needed");

Serial.println("Done");
}

void loop()
{
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
Send UBX binary commands to enable RTCM sentences on Ublox ZED-F9P module
Send UBX binary commands to enable RTCM sentences on u-blox ZED-F9P module
Based on Example7 By: Nathan Seidle
SparkFun Electronics
Updated by Paul Clark to demonstrate setVal8/16/32, newCfgValset8/16/32, addCfgValset8/16/32 and sendCfgValset8/16/32
Date: July 1st, 2019
License: MIT. See license file for more information but you can
basically do whatever you want with this code.

Ublox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
u-blox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
UBX-CFG commands are deprecated; they still work, they just recommend using VALSET, VALGET, and VALDEL
commands instead. This example shows how to use this new command structure.

Expand All @@ -31,16 +31,18 @@ SFE_UBLOX_GPS myGPS;
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("Ublox multi setVal example");
while (!Serial)
; //Wait for user to open terminal
Serial.println("u-blox multi setVal example");

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

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

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

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

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

//Begin with newCfgValset8/16/32
setValueSuccess &= myGPS.newCfgValset8(0x209102bd, 1); //Set output rate of msg 1005 over the I2C port to once per measurement (value is 8-bit (U1))
//setValueSuccess &= myGPS.newCfgValset8(0x209102bd, 1, 7); //Set this and the following settings into Flash/RAM/BBR instead of BBR
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))
//setValueSuccess &= myGPS.newCfgValset8(CFG_MSGOUT_RTCM_3X_TYPE1005_I2C, 1, 7); //Set this and the following settings into Flash/RAM/BBR instead of BBR
//Add extra keyIDs and values using addCfgValset8/16/32
setValueSuccess &= myGPS.addCfgValset8(0x209102cc, 1); //Set output rate of msg 1077 over the I2C port to once per measurement (value is 8-bit (U1))
setValueSuccess &= myGPS.addCfgValset8(0x209102d1, 1); //Set output rate of msg 1087 over the I2C port to once per measurement (value is 8-bit (U1))
setValueSuccess &= myGPS.addCfgValset8(0x209102d6, 1); //Set output rate of msg 1127 over the I2C port to once per measurement (value is 8-bit (U1))
setValueSuccess &= myGPS.addCfgValset8(0x20910318, 1); //Set output rate of msg 1097 over the I2C port to once per measurement (value is 8-bit (U1))
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))
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))
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))
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))
// Add the final value and send the packet using sendCfgValset8/16/32
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))
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))

if (setValueSuccess == true)
{
Expand All @@ -85,5 +87,4 @@ void setup()

void loop()
{

}
3 changes: 3 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ setUART2Output KEYWORD2
setUSBOutput KEYWORD2
setSPIOutput KEYWORD2

getVal KEYWORD2
getVal8 KEYWORD2
getVal16 KEYWORD2
getVal32 KEYWORD2
setVal KEYWORD2
setVal8 KEYWORD2
setVal16 KEYWORD2
Expand Down
Loading