..

Cutting GPS satellite acquisition time

When you turn the key in a car and glance at a DIY GPS speedometer, waiting 45 seconds for NO FIX to turn into a speed reading gets old fast. By the time a cold-started receiver finishes pulling data from the sky, you’ve already left the neighborhood.

I ran into this while building a small in-car driving assistant around a u-blox NEO-M8N GNSS module. None of the fixes require anything exotic on the host side: any microcontroller with a bidirectional serial (or I2C) connection to the GPS module and a few kilobytes of non-volatile storage can layer four complementary techniques so acquisition stays fast whether the car was parked for ten minutes or two weeks.

Why cold starts take so long

To compute a 3D fix, a GNSS receiver needs locks on at least four satellites along with each satellite’s ephemeris.

An ephemeris (borrowed from astronomy’s tables of celestial positions) is a high-precision model describing a single satellite’s exact trajectory and onboard clock behavior over the next 2–4 hours. Unlike the coarser almanac—which gives approximate orbits for the entire constellation and stays valid for months—an ephemeris has to be accurate enough to pinpoint a satellite moving at ~3.9 km/s down to a meter or two. In the GPS navigation message, each satellite’s ephemeris carries:

Two things make a cold start painful:

  1. We don’t know where we are, and we don’t know when we are. Without an approximate position and time, the receiver has no idea which satellites are currently above the horizon or how fast they are moving toward or away from it (which shifts their ~1.575 GHz carrier via the Doppler effect). It has to brute-force search across satellite codes and frequency bins before it can lock onto anything.
  2. The broadcast link is glacial. Satellites transmit their navigation data at 50 bits per second. Even after locking onto a satellite’s signal, decoding its ephemeris subframes takes ~30 seconds under a clear sky—and any blockage from buildings or trees forces a retry.

If the module still has valid ephemeris, time, and position in its Battery-Backed RAM (BBR), you get a hot start in a couple of seconds. If any of those are missing or stale, you’re back to waiting. Everything below is about handing the receiver as many of those missing pieces as possible at boot.

Libraries for talking UBX

All of these settings use u-blox’s binary UBX protocol rather than NMEA. You can build the packets by hand (each frame is just 0xB5 0x62, class, ID, little-endian length, payload, and an 8-bit Fletcher checksum), or let a library handle the framing and acknowledgments:

The examples below use SparkFun’s v2 library alongside the underlying UBX message IDs so you can map them to whatever stack you’re using.

1. Zero-network win: receiver boot configuration

Most NEO-M8N breakouts ship with conservative defaults: 9600 baud, Portable dynamic model, default constellation selection, and AssistNow Autonomous turned off. As long as both RX and TX are wired up, four UBX settings give you an immediate improvement with zero internet access:

It’s also worth bumping the serial port from 9600 to 38400 baud (UBX-CFG-PRT) and disabling unused NMEA sentences (GLL, GSA, GSV, VTG) via UBX-CFG-MSG: it cuts UART clutter and makes streaming aiding packets four times faster.

With SparkFun’s v2 library over a hardware UART (gpsSerial), that whole boot configuration looks like this:

#include <SparkFun_u-blox_GNSS_Arduino_Library.h>

SFE_UBLOX_GNSS gnss;

void configureReceiver(Stream& gpsSerial) {
    if (!gnss.begin(gpsSerial)) return;

    // 3-constellation limit on M8: enable GPS + Galileo + GLONASS, disable BeiDou
    gnss.enableGNSS(true,  SFE_UBLOX_GNSS_ID_GPS);
    gnss.enableGNSS(true,  SFE_UBLOX_GNSS_ID_GALILEO);
    gnss.enableGNSS(true,  SFE_UBLOX_GNSS_ID_GLONASS);
    gnss.enableGNSS(false, SFE_UBLOX_GNSS_ID_BEIDOU);

    gnss.setDynamicModel(DYN_MODEL_AUTOMOTIVE);
    gnss.setAopCfg(1);                  // Enable AssistNow Autonomous
    gnss.setNavigationFrequency(5);     // Optional: 5 Hz updates
    gnss.setSerialRate(38400);          // Faster UART for aiding bursts
    gnss.saveConfiguration();           // Persist to BBR + Flash
}

(Note that enableGNSS() takes one constellation per call—you can’t bitwise-OR the IDs together.)

2. Surviving a dead backup cell: last-position injection

Cheap NEO-M8N boards usually include a tiny rechargeable coin cell (V_BCKP) to keep BBR and the internal RTC alive between trips. In practice, that cell drains after a few parked days—or arrives nearly dead—turning every morning commute back into a cold start.

If your microcontroller has any non-volatile storage at all (internal flash, EEPROM, or an SD card), you can backstop the GPS module yourself:

// Degrees scaled by 1e7; altitude and accuracy in centimeters
int32_t  latE7    = static_cast<int32_t>(lastLatDeg * 1e7);
int32_t  lonE7    = static_cast<int32_t>(lastLonDeg * 1e7);
int32_t  altCm    = 150 * 100;       // rough altitude (150 m)
uint32_t posAccCm = 50000UL * 100UL; // 50 km uncertainty radius

gnss.setPositionAssistanceLLH(latE7, lonE7, altCm, posAccCm);

Even if V_BCKP is completely flat, the receiver now knows roughly where it is and which slice of the sky to search instead of starting blind.

3. Accurate time and 14-day orbits: NTP + AssistNow Offline

AssistNow Autonomous and last-position injection cover routine driving, but if the car sits parked for a week—or you’re booting fresh without prior orbit data—the receiver still lacks UTC time (when we are) and predicted orbits.

Both are small and easy to fetch whenever the vehicle starts up in range of Wi-Fi (for example, in a home garage or driveway). Because the orbit file stays valid for two weeks, the device doesn’t need cellular data or constant connectivity: if the cached file is missing or older than ~7 days, it can grab a quick update over Wi-Fi at startup, shut the radio back off, and run completely offline everywhere else.

A startup sync fetches two things:

  1. UTC time via NTP: Query an NTP server over UDP/123 (or read an external battery-backed RTC if you have one) and inject UBX-MGA-INI-TIME_UTC (0x13 0x40, type 0x10) with a ~2-second accuracy bound.
  2. Predicted orbits via u-blox AssistNow Offline: A single HTTPS GET to:
https://offline-live1.services.u-blox.com/GetOfflineData.ashx?token=<token>&gnss=gps,glo,gal&period=2&resolution=1

(with offline-live2.services.u-blox.com as fallback) returns a binary mgaoffline.ubx file containing 14 days of predicted orbits for GPS, GLONASS, and Galileo. Store that file in flash or on an SD card and refresh it weekly.

One detail worth getting right is not dumping the entire 14-day file straight into the GPS module over UART. Each orbit record in mgaoffline.ubx is a standard UBX-MGA-ANO (0x13 0x20) frame whose target UTC date sits in payload bytes 4–6 (year = 2000 + p[4], month = p[5], day = p[6]). Before sending, scan the cached file, verify each frame’s checksum, and keep only today’s frames (falling back to the first batch if the date isn’t known yet).

Then hand both the UTC time and the filtered UBX-MGA-ANO buffer to the receiver:

// Inject current UTC time (2 s accuracy)
gnss.setUTCTimeAssistance(year, month, day, hour, minute, second,
                          /*nanos=*/0, /*tAccS=*/2);

// Stream today's filtered UBX-MGA-ANO frames; skipTime=true keeps our UTC time
gnss.pushAssistNowData(/*skipTime=*/true, todayMgaBuf, todayMgaLen);

If you’re writing raw UBX instead of using a library, send the filtered buffer in small chunks (e.g., 256 bytes with short pauses) so you don’t overrun the module’s UART input buffer.

4. Don’t forget physics: antennas, windshields, and V_BCKP

None of the UBX aiding above can overcome a receiver that can barely hear a -130 dBm satellite signal. A few physical details make an outsized difference inside a car:

Putting it together

Layer Needs internet? What it provides Role in acquisition
UBX Multi-GNSS + Automotive + AOP No GPS+Galileo+GLONASS + local orbit extrapolation More visible satellites; fast offline starts after first fix
Cached last-position injection No UBX-MGA-INI-POS_LLH (50 km radius) Survives a dead V_BCKP coin cell; answers where we are
Garage Wi-Fi NTP + AssistNow Offline Weekly (optional) UBX-MGA-INI-TIME_UTC + today’s UBX-MGA-ANO orbits Answers when we are and skips 50 bps ephemeris download
Antenna placement & V_BCKP charge No Clean RF SNR + warm BBR Enables 1–2 s hot starts and keeps tracking stable

Layered together, no single failure mode drops you back to a painful cold start. If the backup cell is warm, the receiver locks almost immediately on its own; if it’s drained, non-volatile storage hands it the last position and cached orbits while an occasional Wi-Fi sync in the garage keeps time and the 14-day ephemeris file fresh; and even completely offline for days, three constellations plus AssistNow Autonomous keep startup fast without manual intervention.