Skip to main content
GNSS Documentation
GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Quick Start

Get your first position fix with a minimal example. All three languages follow the same pattern: create → reset → configure → start → read navigation.

#include <cstdio>
#include <jimmypaputto/GnssHat.hpp>

using namespace JimmyPaputto;

auto main() -> int
{
    auto* hat = IGnssHat::create();
    hat->softResetUbloxSom_HotStart();

    GnssConfig config {
        .measurementRate_Hz = 1,
        .dynamicModel = EDynamicModel::Stationary,
        .timepulsePinConfig = TimepulsePinConfig {
            .active = true,
            .fixedPulse = { .frequency = 1, .pulseWidth = 0.1f },
            .pulseWhenNoFix = std::nullopt,
            .polarity = ETimepulsePinPolarity::RisingEdgeAtTopOfSecond
        },
        .geofencing = std::nullopt,
        .rtk = std::nullopt,
        .timing = std::nullopt
    };

    if (!hat->start(config))
    {
        printf("Failed to start GNSS\n");
        return -1;
    }

    while (true)
    {
        const auto nav = hat->waitAndGetFreshNavigation();
        printf("%.6f, %.6f  alt=%.1fm  sats=%d\n",
            nav.pvt.latitude, nav.pvt.longitude,
            nav.pvt.altitude, nav.pvt.visibleSatellites);
    }
}
from jimmypaputto import gnsshat

hat = gnsshat.GnssHat()
hat.soft_reset_hot_start()

config = {
    'measurement_rate_hz': 1,
    'dynamic_model': gnsshat.DynamicModel.PORTABLE,
    'timepulse_pin_config': {
        'active': True,
        'fixed_pulse': { 'frequency': 1, 'pulse_width': 0.1 },
        'polarity': gnsshat.TimepulsePolarity.RISING_EDGE
    },
    'geofencing': None
}

if not hat.start(config):
    print("Failed to start GNSS")
    exit(1)

while True:
    nav = hat.wait_and_get_fresh_navigation()
    print(nav)
#include <stdio.h>
#include <jimmypaputto/GnssHat.h>

int main(void)
{
    jp_gnss_hat_t* hat = jp_gnss_hat_create();
    jp_gnss_hat_soft_reset_hot_start(hat);

    jp_gnss_gnss_config_t config;
    jp_gnss_gnss_config_init(&config);
    config.measurement_rate_hz = 1;
    config.dynamic_model = JP_GNSS_DYNAMIC_MODEL_STATIONARY;
    config.timepulse_pin_config.active = true;
    config.timepulse_pin_config.fixed_pulse.frequency = 1;
    config.timepulse_pin_config.fixed_pulse.pulse_width = 0.1f;
    config.timepulse_pin_config.polarity = JP_GNSS_TIMEPULSE_POLARITY_RISING_EDGE;

    if (!jp_gnss_hat_start(hat, &config))
    {
        printf("Failed to start GNSS\n");
        jp_gnss_hat_destroy(hat);
        return -1;
    }

    jp_gnss_navigation_t nav;
    while (jp_gnss_hat_wait_and_get_fresh_navigation(hat, &nav))
    {
        printf("%.6f, %.6f  alt=%.1fm  sats=%d\n",
            nav.pvt.latitude, nav.pvt.longitude,
            nav.pvt.altitude, nav.pvt.visible_satellites);
    }

    jp_gnss_hat_destroy(hat);
    return 0;
}

What Happens

  1. create() — detects which HAT is installed and returns the correct implementation
  2. softReset / HotStart — resets the u-blox module while preserving ephemeris and almanac data for faster time-to-first-fix
  3. start(config) — sends configuration to the module via UBX protocol and starts background data acquisition
  4. waitAndGetFreshNavigation() — blocks until a new navigation solution arrives (at the configured measurement rate)

Expected Output

52.229700, 21.012200  alt=120.3m  sats=12
52.229701, 21.012199  alt=120.2m  sats=12
52.229700, 21.012201  alt=120.4m  sats=13
Note
After a cold start, it may take 30–60 seconds to get a first fix. A hot start (with preserved almanac) typically fixes in under 3 seconds.

Next Steps

  • Configuration — customize measurement rate, dynamic model, and features
  • Navigation Data — understand all the fields in the Navigation struct
  • Examples — explore RTK, geofencing, time marks, and more