Notecard Real-Time Clock
This application note provides technical details and implementation guidance for using the real-time clock (RTC) functionality on Notecard, including crystal specifications, accuracy considerations, and best practices for time-sensitive applications.
Overview
The Notecard includes a built-in RTC that provides reasonably accurate timekeeping for your applications. The RTC is synchronized with network time when the Notecard connects to cellular, Wi-Fi, or satellite networks, and maintains time locally between synchronization events.
The RTC subsystem uses a crystal oscillator that produces a precise "heartbeat" signal, which the RTC uses to track time. This allows the Notecard to maintain time even when disconnected from the network, making it suitable for applications that require timestamping of events, scheduled operations, and time-based logic.
How the RTC Works
When a Notecard first powers on, the RTC has no knowledge of the current time. Upon the first successful sync to Notehub (via cellular, Wi-Fi, or satellite connection), the Notecard synchronizes its RTC with the time provided by Notehub. The Notecard obtains accurate time references from cellular towers or GPS (when available), which Notehub uses to provide precise time synchronization.
Once synchronized, the RTC continues to track time using its local crystal oscillator, even when the Notecard is offline or in low-power modes. The RTC primarily serves to track intervals between scheduled operations (such as "how long until the next sync") rather than maintaining absolute precision.
The Notecard automatically resynchronizes its RTC during subsequent Notehub syncs, which corrects any drift that may have accumulated since the last synchronization. This means that even if the RTC drifts while offline, your data will still reach Notehub with accurate timestamps once connectivity is restored.
Crystal Specifications
All Notecard models use a 32.768 kHz crystal oscillator for their RTC subsystem. The crystal specifications vary slightly between Notecard and Notecard (legacy) models.
Notecards
Notecards use crystals with:
- Nominal frequency: 32.768 kHz
- Accuracy at 25°C: ±20 ppm (±0.002%)
- Drift at 25°C: ±2 seconds per day
Notecards have additional temperature characterization data showing drift across the full operating temperature range:
| Temperature | Drift | Time Drift per Day (Approximation) |
|---|---|---|
| -40°C | Up to -175 ppm (-0.018%) slower | -15 seconds |
| 25°C | ±20 ppm (±0.002%) | ±2 seconds |
| 85°C | Up to -140 ppm (-0.014%) slower | -12 seconds |
These specifications are typical for crystal oscillators used in consumer electronics, including smartphones. At approximately 25°C, the crystal oscillator at its most stable. More precise timing would require temperature-compensated crystal oscillators (TCXO), which are significantly more expensive.
Accuracy Considerations
While crystal oscillators are reasonably precise in stable conditions, several environmental and operational factors can cause the RTC to drift over time:
Temperature Effects
Crystal oscillators are sensitive to temperature changes. Most crystals have a temperature coefficient that causes their frequency to vary with temperature. This means that:
- In extreme heat, the crystal may oscillate faster or slower than its nominal frequency, causing time to drift
- In extreme cold, similar drift can occur
- Temperature changes during operation can cause accumulated drift over time
- The rate of drift is typically non-linear with temperature and varies by crystal specification
Aging and Long-Term Drift
All crystal oscillators experience some degree of aging over time:
- Frequency can drift slowly over months and years of operation
- The rate of aging varies by crystal type and operating conditions
- Network time synchronization helps compensate for long-term drift
The Notecard is designed to be tolerant of RTC drift. Even if the local timebase varies due to temperature changes or infrequent connectivity, the Notecard will still successfully sync your data to Notehub. Time-critical timestamps are corrected during synchronization, ensuring your data reaches Notehub with accurate timestamps regardless of local RTC drift.
When Precision is Required
While the Notecard's RTC is sufficient for most applications, some use cases may require higher precision timing. If your application requires sub-second accuracy over days or weeks without Notehub connectivity, consider:
- Using an external TCXO (Temperature Compensated Crystal Oscillator) based RTC module
- Implementing more frequent Notehub synchronization (e.g. increase the
outboundandinboundsync times in thehub.setrequest) - Using GPS timing on Notecard models with GPS (when GPS lock is available)
RTC Synchronization
Automatic Synchronization
The Notecard automatically synchronizes its RTC during:
- First sync: When the Notecard first syncs to Notehub after power-on
- Periodic syncs: During each subsequent sync session with Notehub
- Manual sync requests: When explicitly requested via API
No special configuration is required for automatic RTC synchronization, it happens as part of the Notecard's Notehub sync process. The Notecard obtains time from cellular towers or GPS, which provides highly accurate time references for synchronization.
Checking RTC Status
You can check the current RTC time and synchronization status using the card.time request:
{"req": "card.time"}This returns the current time in both Unix timestamp and human-readable formats,
along with the timezone information.
Before the Notecard has successfully synced
to Notehub, this request will return {"zone":"UTC,Unknown"} indicating that
time has not yet been obtained.
Time Zones
The Notecard maintains time in UTC internally. Your host application can convert UTC time to local time zones as needed.
Power Considerations
The RTC continues to operate during all Notecard power modes:
Active Mode
The RTC operates normally with full accuracy during active operation.
Low-Power Modes
The RTC continues to track time during sleep and hibernation modes. The crystal oscillator remains active to maintain time, but power consumption is minimal (current consumption can be measured in microamperes).
Power Loss
If the Notecard completely loses power (e.g. VBAT disconnected), the RTC will lose track of time and will need to resynchronize when power is restored and a network connection is established.