66 License: MIT. See license file for more information but you can
77 basically do whatever you want with this code.
88
9- This example shows how to query a u-blox module for its UART1 settings and
9+ This example shows how to query a Ublox module for its UART1 settings and
1010 then change them if the settings aren't what we want.
1111
1212 Note: getVal/setVal/delVal are only support in u-blox protocol versions 27 and higher.
@@ -33,17 +33,19 @@ void setup()
3333 Serial.begin (115200 );
3434 while (!Serial)
3535 ; // Wait for user to open terminal
36- Serial.println (" SparkFun u-blox Example" );
36+ Serial.println (" SparkFun Ublox Example" );
3737
3838 Wire.begin ();
3939
4040 if (myGPS.begin () == false ) // Connect to the Ublox module using Wire port
4141 {
42- Serial.println (F (" u-blox GPS not detected at default I2C address. Please check wiring. Freezing." ));
42+ Serial.println (F (" Ublox GPS not detected at default I2C address. Please check wiring. Freezing." ));
4343 while (1 )
4444 ;
4545 }
4646
47+ bool response = true ;
48+
4749 // Read the settings from RAM (what the module is running right now, not BBR, Flash, or default)
4850 uint8_t currentUART1Setting_ubx = myGPS.getVal8 (UBLOX_CFG_UART1INPROT_UBX);
4951 uint8_t currentUART1Setting_nmea = myGPS.getVal8 (UBLOX_CFG_UART1INPROT_NMEA);
@@ -62,7 +64,6 @@ void setup()
6264 Serial.println (" Updating UART1 configuration" );
6365
6466 // setVal sets the values for RAM, BBR, and Flash automatically so no .saveConfiguration() is needed
65- bool response = true ;
6667 response &= myGPS.setVal8 (UBLOX_CFG_UART1INPROT_UBX, 1 ); // Enable UBX on UART1 Input
6768 response &= myGPS.setVal8 (UBLOX_CFG_UART1INPROT_NMEA, 1 ); // Enable NMEA on UART1 Input
6869 response &= myGPS.setVal8 (UBLOX_CFG_UART1INPROT_RTCM3X, 0 ); // Disable RTCM on UART1 Input
@@ -73,7 +74,23 @@ void setup()
7374 Serial.println (" SetVal succeeded" );
7475 }
7576 else
76- Serial.println (" Nothing to change" );
77+ Serial.println (" No port change needed" );
78+
79+ // Change speed of UART2
80+ uint32_t currentUART2Baud = myGPS.getVal32 (UBLOX_CFG_UART2_BAUDRATE);
81+ Serial.print (" currentUART2Baud: " );
82+ Serial.println (currentUART2Baud);
83+
84+ if (currentUART2Baud != 57600 )
85+ {
86+ response &= myGPS.setVal32 (UBLOX_CFG_UART2_BAUDRATE, 57600 );
87+ if (response == false )
88+ Serial.println (" SetVal failed" );
89+ else
90+ Serial.println (" SetVal succeeded" );
91+ }
92+ else
93+ Serial.println (" No baud change needed" );
7794
7895 Serial.println (" Done" );
7996}
0 commit comments