LILYGO T-Beam // NEO-6M - [22.05.2024]¶
Introduction¶
The LILYGO T-Beam carries a u-blox NEO-6M GPS module that defaults to 9600 baud and 1 Hz update rate. This guide reconfigures the module to 115200 baud and 5 Hz using two UBX configuration messages.
The reconfiguration requires two separate UBX messages because they control independent settings:
UBX-CFG-PRT(class0x06, ID0x00) — changes the UART baud rate.UBX-CFG-RATE(class0x06, ID0x08) — changes the navigation/measurement rate.
Warning
UBX-CFG-PRT and UBX-CFG-RATE are not interchangeable. Sending only UBX-CFG-RATE will leave the baud rate untouched.
Reference: u-blox 6 Receiver Description / Protocol Spec (local mirror).
Step 1 - Generate UBX Packets¶
Use the generators below to build custom UBX packets. Checksums are computed automatically using the UBX Fletcher-8 algorithm.
Sets the UART1 baud rate via UBX-CFG-PRT. Payload: port ID, mode (8N1), baud rate, protocol masks.
Click Generate to build the packet.
Sets the navigation measurement rate via UBX-CFG-RATE. Common values: 1000 ms = 1 Hz, 200 ms = 5 Hz, 100 ms = 10 Hz.
Click Generate to build the packet.
Paste any UBX payload (class through end of payload, without the 0xB5 0x62 header and without the checksum bytes) and compute CK_A / CK_B.
Click Calculate to compute the checksum.
Step 2 - Reconfigure the NEO-6M¶
Open the serial port at the default 9600 baud, send the baud-rate change, then the rate change, then reopen at the new baud rate.
void sendPacket(byte *packet, byte len)
{
for (byte i = 0; i < len; i++)
{
GPSSerial.write(packet[i]);
}
}
void setup() {
// 1. Connect at the NEO-6M's default 9600 baud
GPSSerial.begin(9600, SERIAL_8N1, GPS_RX, GPS_TX);
// 2. UBX-CFG-RATE: 5 Hz (measRate=200ms, navRate=1, timeRef=GPS)
// Sent BEFORE the baud change so it can't arrive at 9600 after the
// GPS has already switched to 115200.
byte cfg_rate[14] = { // (1)!
0xB5, 0x62, 0x06, 0x08, 0x06, 0x00,
0xC8, 0x00, 0x01, 0x00, 0x01, 0x00,
0xDE, 0x6A
};
sendPacket(cfg_rate, sizeof(cfg_rate));
// 3. UBX-CFG-PRT: UART1 -> 115200 8N1, UBX+NMEA+RTCM in, UBX+NMEA out
byte cfg_prt[28] = { // (2)!
0xB5, 0x62, 0x06, 0x00, 0x14, 0x00,
0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00,
0x00, 0xC2, 0x01, 0x00, 0x07, 0x00, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00,
0xC0, 0x7E
};
sendPacket(cfg_prt, sizeof(cfg_prt));
// 4. Drain the TX FIFO before tearing the port down — Serial.end()
// on ESP32 does NOT guarantee outstanding bytes are transmitted.
GPSSerial.flush();
GPSSerial.end();
// 5. Reopen at the new baud rate
GPSSerial.begin(115200, SERIAL_8N1, GPS_RX, GPS_TX);
}
void loop() {
// read GPS data here
}
- CFG-RATE breakdown:
B5 62sync,06 08class/ID,06 00length (6 bytes),C8 00= 200 ms (5 Hz),01 00navRate,01 00timeRef (GPS),DE 6Achecksum. - CFG-PRT breakdown:
B5 62sync,06 00class/ID,14 00length (20 bytes),01portID (UART1),00reserved,00 00txReady,D0 08 00 00mode (8N1),00 C2 01 00= 115200 baud (little-endian),07 00inProtoMask (UBX+NMEA+RTCM),03 00outProtoMask (UBX+NMEA),00 00flags,00 00reserved2,C0 7Echecksum.
Note
These settings are stored in RAM and reset on power-cycle. To persist them, follow up with a UBX-CFG-CFG save message: