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

Timepulse

The u-blox module outputs a configurable pulse signal on GPIO 5. This is typically used as a PPS (Pulse Per Second) signal for time synchronization. On supported HATs, the same signal also drives the LED, so changing the timepulse configuration may also affect the visible blink pattern.

TimepulsePinConfig

FieldC++ TypeDescription
activeboolEnable or disable the timepulse output
fixedPulsePulsePulse configuration when the receiver has a GNSS fix
pulseWhenNoFixoptional<Pulse>Optional separate pulse config when there is no fix. If omitted, no pulse is output without a fix
polarityETimepulsePinPolarityWhich edge aligns with the top of the second

Pulse

FieldC++ TypeDescription
frequencyuint32_tPulse frequency in Hz
pulseWidthfloatDuty cycle as a fraction — 0.0 to 0.99

Polarity

ValueC++CPython
Rising edge at top of secondRisingEdgeAtTopOfSecondJP_GNSS_TIMEPULSE_POLARITY_RISING_EDGERISING_EDGE
Falling edge at top of secondFallingEdgeAtTopOfSecondJP_GNSS_TIMEPULSE_POLARITY_FALLING_EDGEFALLING_EDGE

Signal Shape

The waveform below starts with an annotated 1 Hz pulse at 10% duty cycle so you can see how polarity decides whether the rising or falling edge lands exactly on the top of the second. The lower examples show the same GPIO 5 output at 5 Hz / 10%, 10 Hz / 50%, and a fix-dependent transition where pulseWhenNoFix uses one waveform until the receiver has a fix and fixedPulse takes over.

Timepulse waveform examples showing an annotated 1 Hz waveform with polarity-aligned edges, simplified 5 Hz and 10 Hz waveforms with period and pulseWidth labels, and a fourth example that switches from 5 Hz without fix to 10 Hz with fix. Timepulse waveform examples showing an annotated 1 Hz waveform with polarity-aligned edges, simplified 5 Hz and 10 Hz waveforms with period and pulseWidth labels, and a fourth example that switches from 5 Hz without fix to 10 Hz with fix.
Polarity controls which edge aligns to the second boundary, while frequency and pulseWidth control the rest of the waveform. Depending on the fix state, the receiver applies a different waveform.

If the receiver has no fix, pulseWhenNoFix can emit a different waveform or disable the output entirely. A common pattern is a slower pulse / no pulse before fix and a different period or duty cycle once the receiver is locked.

Examples

config.timepulsePinConfig = TimepulsePinConfig {
    .active = true,
    .fixedPulse = { .frequency = 1, .pulseWidth = 0.1f },
    .pulseWhenNoFix = std::nullopt,
    .polarity = ETimepulsePinPolarity::RisingEdgeAtTopOfSecond
};
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;
config['timepulse_pin_config'] = {
    'active': True,
    'fixed_pulse': { 'frequency': 1, 'pulse_width': 0.1 },
    'pulse_when_no_fix': None,
    'polarity': gnsshat.TimepulsePolarity.RISING_EDGE
}
Note
Kernel PPS Conflict — If you use the kernel PPS driver (dtoverlay=pps-gpio,gpiopin=5) for chrony/gpsd, do not call enableTimepulse() from the library — both use GPIO 5 and cannot coexist.