Skip to content

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 (class 0x06, ID 0x00) — changes the UART baud rate.
  • UBX-CFG-RATE (class 0x06, ID 0x08) — 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.

C byte array:
Click Generate to build the packet.
Raw hex:
Breakdown:

Sets the navigation measurement rate via UBX-CFG-RATE. Common values: 1000 ms = 1 Hz, 200 ms = 5 Hz, 100 ms = 10 Hz.

C byte array:
Click Generate to build the packet.
Raw hex:
Breakdown:

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.

setup() — NEO-6M reconfiguration
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
}
  1. CFG-RATE breakdown: B5 62 sync, 06 08 class/ID, 06 00 length (6 bytes), C8 00 = 200 ms (5 Hz), 01 00 navRate, 01 00 timeRef (GPS), DE 6A checksum.
  2. CFG-PRT breakdown: B5 62 sync, 06 00 class/ID, 14 00 length (20 bytes), 01 portID (UART1), 00 reserved, 00 00 txReady, D0 08 00 00 mode (8N1), 00 C2 01 00 = 115200 baud (little-endian), 07 00 inProtoMask (UBX+NMEA+RTCM), 03 00 outProtoMask (UBX+NMEA), 00 00 flags, 00 00 reserved2, C0 7E checksum.

Note

These settings are stored in RAM and reset on power-cycle. To persist them, follow up with a UBX-CFG-CFG save message:

// UBX-CFG-CFG: save current config to all storage
byte cfg_save[21] = {
    0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00,
    0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x17,
    0x31, 0xBF
};
sendPacket(cfg_save, sizeof(cfg_save));