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:
- Keplerian orbital elements: the shape and orientation of the satellite’s elliptical orbit (semi-major axis, eccentricity, inclination, longitude of the ascending node, argument of perigee, and mean anomaly at a reference epoch).
- Perturbation and drift corrections: rate-of-change terms and harmonic corrections that account for Earth’s non-spherical gravity field, solar and lunar pull, and orbital precession.
- Satellite clock corrections: clock bias, drift, drift rate, and signal group delay. Radio waves travel roughly 30 cm per nanosecond, so the receiver needs nanosecond-level clock corrections to turn signal arrival times into accurate distances.
- Health and validity metadata: whether the satellite is healthy, its expected ranging accuracy, and the reference epoch / issue number so the receiver knows when the ephemeris expires.
Two things make a cold start painful:
- 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.
- 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:
- Arduino-compatible MCUs (AVR, ARM, STM32, RP2040, ESP32, etc.): SparkFun’s u-blox GNSS Arduino Library works over both UART and I2C. One version note: use v2.x for M8-series chips like the NEO-M8N; v3/v4 moved to the newer key-value (
VALSET) configuration API used by M9, M10, and F9 modules. - Other C / RTOS / Linux targets: u-blox maintains
ubxlibin portable C (Zephyr, FreeRTOS, STM32Cube, Linux), andpyubx2covers Python hosts like a Raspberry Pi.
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:
- Multi-GNSS (
UBX-CFG-GNSS,0x06 0x3E): Enable GPS, Galileo, and GLONASS concurrently, and explicitly disable BeiDou. The u-blox M8 engine caps concurrent tracking at three constellations, so you can’t turn all four on at once. Tracking three constellations puts far more satellites above the horizon, which speeds up initial lock and keeps geometry usable behind a windshield or between buildings. - Automotive dynamic model (
UBX-CFG-NAV5,0x06 0x24,dynModel = 4): Tunes the navigation filter for road-vehicle acceleration and velocity profiles rather than handheld walking use. - AssistNow Autonomous (
UBX-CFG-NAVX5,0x06 0x23,aopCfg = 1): Probably the most underused feature on u-blox M8 modules. Once the receiver gets a normal fix and decodes broadcast ephemeris, it extrapolates future satellite orbits internally and stores them in flash/BBR. Subsequent starts stay fast for days with zero network access. - Persist settings (
UBX-CFG-CFG,0x06 0x09): Save port, message, and navigation configuration to both BBR and onboard flash so they survive power cycles.
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:
- While driving with a valid fix, persist
(lat, lon)in a tiny record with a CRC32 check—throttled to once every few minutes (and once more before powering down or sleeping) to avoid flash wear. - On the next boot, read that record back and inject a
UBX-MGA-INI-POS_LLH(0x13 0x40, type0x01) message with a conservative 50 km uncertainty radius:
// 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:
- 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, type0x10) with a ~2-second accuracy bound. - Predicted orbits via u-blox AssistNow Offline: A single HTTPS
GETto:
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:
- Patch orientation and clearance: On a ceramic patch antenna, the flat beige/silver square needs to face up toward the sky, away from PCBs, display ribbons, and metal dash trim.
- Heated and athermic windshields: Modern IR-reflective (metal-coated) or electrically heated windshields can attenuate L1 GNSS signals by 10–20 dB. Mounting near the uncoated dotted frit cutout behind the rearview mirror—or switching to a cheap active external SMA antenna—often makes a bigger difference than any software change.
- Charge the backup cell once: Leaving the NEO-M8N powered for ~30 minutes during initial setup charges its onboard
V_BCKPcell so stops shorter than ~4 hours get genuine 1–2 second hot starts without waiting on aiding packets at all. - Separate link bugs from RF bugs: In your UI or logs, distinguish
NO GPS(no valid NMEA bytes arriving) fromNO FIX(module alive, waiting on satellites), and keep an eye on satellite count,HDOP, and NMEA checksum error counts so you know immediately whether a slow fix is an antenna problem or a serial issue.
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.