Skip to content

ENABLE_RTC

Flag to enable absolute time tracking via RTC (Real-Time Clock).

Controls whether unix timestamp (microseconds since 1970-01-01 UTC) is included in sensor event output and time-related commands are available.


v2 (Always Enabled)

In v2, RTC is a standard feature — always enabled, no flag required.

The detected_us field is always present in event output:

{"type":"event","status":"ok","sent_us":1748012345678901,"hit1":45,"hit2":38,"hit3":42,"detected_us":1748012345678456}

RTC commands are always available:

  • GET_RTC_TIME - Get current unix timestamp (seconds)
  • SET_RTC_TIME <unixtime> - Set RTC time
  • GET_RTC_TIME_MS - Get current unix timestamp (milliseconds)
  • GET_RTC_TIME_US - Get current unix timestamp (microseconds)

v1 (Configurable)

In v1, RTC is controlled by the ENABLE_RTC build flag.

Default

  • v1.10.0+: Enabled by default (ENABLE_RTC=1)
  • v0: Disabled by default (ENABLE_RTC=0)

Options

  • ENABLE_RTC=1: Include detected_us field in event output, enable RTC commands
  • ENABLE_RTC=0: Disable RTC tracking (zero overhead)

Override with platformio.override.ini

[env:esp32dev-v1]
build_flags =
    -D ENABLE_RTC=1

Features

  • Precision: Microseconds (64-bit unix timestamp)
  • Hardware: ESP32 internal RTC (persists across power cycles)
  • Commands: GET_RTC_TIME, SET_RTC_TIME, GET_RTC_TIME_MS, GET_RTC_TIME_US
  • Output field: detected_us in JSONL event output
  • Memory: ~800 bytes flash, ~8 bytes RAM

Use Cases

Enable RTC (ENABLE_RTC=1) for:

  • Multi-detector synchronization to absolute time
  • Long-term event correlation with external time-series data
  • Research deployments requiring precise timing alignment

Disable RTC (ENABLE_RTC=0, v1/v0 only) for:

  • Simple single-detector deployments where relative timing is sufficient
  • Minimal firmware size requirements

History

  • v1.9.4 — Initial implementation (unix_timestamp in seconds)
  • v1.19.0 — Precision upgrade: unix_timestampdetected_us (seconds → microseconds)
  • v2.3.0 — RTC promoted to always-enabled standard feature