Skip to content

Using GPS as Time Source

Matthias Prinke edited this page Mar 7, 2026 · 19 revisions

Use Case

BresserWeatherSensorLW's README – Real-Time Clock (RTC) lists several option for setting the microcontroller's internal RTC from a time source:

  • LoRaWAN Network Time
  • LoRaWAN Downlink Command
  • Separate RTC with backup battery

Potential reasons for using a GPS as time source:

  • Time is set automatically
  • Timezone could be set automatically
  • High accuracy (no unknown latency as in case of LoRaWAN network time)

Interfacing

Warning

Check the GPS module's datasheet for the correct power supply voltage and I/O voltage levels! Using the wrong voltage can damage the GPS module or the microcontroller.

The following are common GPS module configurations:

  1. 3.3V power supply and 3.3V I/O levels
  2. 5V power supply and 3.3V I/O levels (internal voltage regulator)
  3. 5V power supply and 5V I/O levels (LEVEL SHIFTER REQUIRED!)

Power Management

A modern GPS module still has a much higher power consumption than an RTC module. For battery/solar powered applications, it makes sense to enable GPS only for synchronizing the MCU's internal RTC.

Depending on the GPS receiver chip/module, the following options exist:

  1. Dedicated enable input –
    Rarely available with low budget modules.

  2. (Proprietary) serial interface command for power down/wake up –
    Rarely available, often poorly documented, sometimes poorly implemented
    (e.g. power down works/wake up requires power cycling).

  3. Controlling the module's power supply with an external load switch –
    Universal solution, but extra hardware required – applied in BresserWeatherSensorLW.

 ESP32                          Load Switch                          
┌─────────────────┐             ┌────────┐                           
│                 │             │Vin Vout├────┐                      
│                 │             │        │    │                      
│                 │             │        │    │     GPS Module       
│            GPIO ├────────────►│Enable  │    │    ┌────────────────┐
│                 │             │        │    │    │                │
│                 │           ┌─┤GND     │    └───►│VCC             │
│                 │           │ └────────┘         │                │
│                 │           │                    │                │
│             RX  │◄──────────┼────────────────────┤TX              │
│                 │           │                    │                │
│                 │           │                    │RX              │
│                 │           │                    │                │
│                 │           │                    │                │
│                 │           │                    │                │
│                 │           │                    │                │
│             GND ├───────────┴────────────────────┤GND             │
│                 │                                │                │
└─────────────────┘                                └────────────────┘

(drawn with asciiflow)

Arduino GPS Libraries

  • TinyGPSPlus – Used by BresserWeatherSensorLW.
  • Adafruit_GPS – Targeted to Adafruit's own modules, but probably also useful for other hardware.

GPS Module Selection Guide

  • Size
  • Mechanical integration – mounting & antenna
  • Supply voltage
  • Energy consumption – operating current and time-to-fix
  • Supported satellite systems – many supported systems increase the chance of a fix/reduce the time-to-fix in averse receiving conditions (e.g. indoors)
  • Sensitivity & number of channels
  • Power management features (see Power Management)
  • Price

My current choice: M5Stack Unit GPS v1.1

Clone this wiki locally