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

Geofencing

Configure up to 4 circular geofences. The receiver reports per-fence and combined Inside/Outside/Unknown state in every navigation update.

Note
HAT Compatibility — Geofencing is available on the L1 GNSS HAT and L1/L5 RTK HAT. It is not supported on the TIME HAT.

Configuration Fields

Field C++ Type Description
geofences vector<Geofence> 1–4 geofence zones
confidenceLevel uint8_t Confidence level 0–5 (sigma). Higher = more certain before reporting Inside/Outside
pioPinPolarity optional<EPioPinPolarity> Optional PIO pin output polarity. Omit to disable hardware output

Geofence

Field Type Description
lat float Center latitude in degrees
lon float Center longitude in degrees
radius float Radius in meters

PIO Pin Polarity

Value C++ C Python Description
Low = Inside LowMeansInside JP_GNSS_PIO_PIN_POLARITY_LOW_MEANS_INSIDE LOW_MEANS_INSIDE Pin goes LOW when inside any geofence
Low = Outside LowMeansOutside JP_GNSS_PIO_PIN_POLARITY_LOW_MEANS_OUTSIDE LOW_MEANS_OUTSIDE Pin goes LOW when outside all geofences

The PIO pin (pin 6 on the u-blox module) drives an LED and relay on the HAT for hardware geofence signaling.

Examples

config.geofencing = GnssConfig::Geofencing {
    .geofences = {
        Geofence { .lat = 52.2297f, .lon = 21.0122f, .radius = 100.0f },
        Geofence { .lat = 52.2400f, .lon = 21.0200f, .radius = 50.0f }
    },
    .confidenceLevel = 3,
    .pioPinPolarity = EPioPinPolarity::LowMeansInside
};
config['geofencing'] = {
    'confidence_level': 3,
    'pin_polarity': gnsshat.PioPinPolarity.LOW_MEANS_INSIDE,
    'geofences': [
        { 'lat': 52.2297, 'lon': 21.0122, 'radius': 100.0 },
        { 'lat': 52.2400, 'lon': 21.0200, 'radius': 50.0 }
    ]
}
jp_gnss_geofence_t fence1 = { .lat = 52.2297f, .lon = 21.0122f, .radius = 100.0f };
jp_gnss_geofence_t fence2 = { .lat = 52.2400f, .lon = 21.0200f, .radius = 50.0f };
jp_gnss_gnss_config_add_geofence(&config, fence1);
jp_gnss_gnss_config_add_geofence(&config, fence2);
config.geofencing_cfg.confidence_level = 3;
config.geofencing_cfg.pio_enabled = true;
config.geofencing_cfg.pin_polarity = JP_GNSS_PIO_PIN_POLARITY_LOW_MEANS_INSIDE;

Runtime Status

Geofencing status is reported in every Navigation update via navigation.geofencing:

Field Description
geofencingStatus Active or NotAvailable
combinedState Combined state across all fences: Inside, Outside, or Unknown
geofencesStatus[i] Per-fence state (up to 4)

See Geofencing Feature for runtime usage details.