Kembali ke Blog

Cycling Sensor Data Buffering & Offline Storage

Sensor & Telemetri

Sensor Data Buffering and Offline Storage

A cycling sensor that stops recording the moment Bluetooth drops is a sensor that produces hole-ridden data, because BLE and ANT+ connections fail constantly in the real world — behind a hill, in a tunnel, when the phone sleeps, or amid RF interference from urban traffic. Cycling sensor data buffering solves this by giving the sensor its own local memory so it keeps capturing every sample during a disconnect and syncs the backlog automatically when the link returns. The DIDI.BIKE sensor carries an 8 MB internal flash buffer sized to hold roughly two hours of full 6-axis, 100 Hz telemetry — enough to ride through any realistic outage without losing a single data point.

Why Connections Drop

Wireless telemetry links are fragile on a bike. Common causes of disconnection include:

  • Terrain masking: Hills, valleys, and dense woodland attenuate the 2.4 GHz signal.
  • Phone power management: iOS and Android aggressively suspend background BLE sessions, dropping the link when the app is not foregrounded.
  • RF interference: Wi-Fi networks, other riders' sensors, and Bluetooth headphones all share the same band.
  • Distance: The effective range of a phone in a jersey pocket can drop to under 5 m when the body absorbs signal.

Field testing shows that a typical two-hour ride experiences anywhere from a handful to dozens of brief connection drops, each lasting a few seconds to several minutes. Without buffering, every drop becomes a permanent gap.

The Buffering Architecture

A robust buffering system has three stages:

  1. Continuous local sampling: The sensor's IMU writes every sample to a ring buffer in RAM regardless of connection state, so capture never pauses.
  2. Flash persistence: When the wireless link is down, samples are flushed from the RAM ring buffer to non-volatile flash, tagged with a precise timestamp from the sensor's real-time clock.
  3. Transparent sync: When the link returns, the sensor streams the buffered backlog interleaved with live data. The receiving app reassembles them into a seamless timeline.

The DIDI.BIKE sensor implements all three stages. Its 8 MB flash partition is the durable store that survives a dead battery or a crashed app; the RAM ring buffer is the low-latency path used during momentary dropouts.

Sizing the Buffer: The Math

To specify a buffer you need to know the data rate. For the DIDI.BIKE sensor:

  • Axes: 6 (3 gyro + 3 accel)
  • Sampling rate: 100 Hz100\text{ Hz}
  • Resolution: 16 bits per axis = 2 bytes

Per-sample payload:

6×2 bytes=12 bytes/sample6 \times 2\text{ bytes} = 12\text{ bytes/sample}

Data rate:

12 bytes/sample×100 samples/s=1200 bytes/s1.2 KB/s12\text{ bytes/sample} \times 100\text{ samples/s} = 1200\text{ bytes/s} \approx 1.2\text{ KB/s}

Hourly volume:

1.2 KB/s×3600 s4.3 MB/h1.2\text{ KB/s} \times 3600\text{ s} \approx 4.3\text{ MB/h}

With an 8 MB buffer the sensor holds:

8 MB4.3 MB/h1.86 h\frac{8\text{ MB}}{4.3\text{ MB/h}} \approx 1.86\text{ h}

That is nearly two hours of complete ride telemetry — comfortably longer than any realistic single-ride outage. Multi-day tour riders who sync once per evening would need the sensor to prune low-value data or raise the buffer, but for the overwhelming majority of rides the 8 MB capacity is ample.

Metric Value
Axes sampled 6
Sample rate 100 Hz
Bytes per sample 12
Data rate ~1.2 KB/s
Per-hour volume ~4.3 MB
Buffer capacity 8 MB
Buffer endurance ~1.9 hours

Timestamp Integrity

Buffered data is only useful if it can be placed correctly in the ride timeline. Each buffered sample carries a timestamp from the sensor's onboard real-time clock, which is synchronized to the phone's clock whenever a connection is active. On reconnection, the app uses these timestamps to slot the buffered samples into the right positions, detect any overlap with live data, and discard duplicates. A clock drift of even a few seconds would misalign cadence and GPS tracks, so the DIDI.BIKE sensor uses a temperature-compensated oscillator to keep drift under a few parts per million.

Sync Strategies

There are two common approaches to draining the buffer after a reconnection:

  • Interleaved streaming: The sensor transmits a mix of live samples and backlogged samples, prioritizing the newest live data so the user sees real-time numbers, while trickling the backlog in the spare bandwidth. This is the approach the DIDI.BIKE sensor uses over BLE 5.0, because it preserves sub-10 ms latency for live telemetry while still draining the buffer.
  • Bulk dump then catch-up: The sensor halts live transmission, dumps the entire backlog as fast as possible, then resumes live mode. This drains the buffer fastest but sacrifices real-time display during the dump, making it suitable only for post-ride sync rather than mid-ride recovery.

See our cycling telemetry protocols article for the bandwidth and packet-structure details that make interleaved streaming feasible.

Power Cost of Buffering

Writing to flash consumes energy, but modern NAND flash is efficient enough that continuous buffering does not dominate the power budget. The DIDI.BIKE sensor's 120-hour battery life is measured under a worst-case profile that includes intermittent buffering. For the full breakdown of where power goes, see sensor power consumption and battery life.

When Buffering Is Not Needed

A sensor that streams only to a dedicated bike computer with a robust, short-range connection may experience so few dropouts that buffering adds cost without benefit. But any sensor designed to pair with a smartphone — where OS power management and app lifecycle are unpredictable — needs a buffer to deliver trustworthy data. The DIDI.BIKE sensor's design assumes the smartphone use case, which is why the 8 MB buffer is standard rather than optional.

For the broader picture of how buffering fits into the end-to-end telemetry pipeline, the pillar cycling sensors and telemetry guide is the starting point, and OTA firmware updates explains how the buffer is also used to stage firmware images safely.

FAQ

How much data does a cycling sensor generate per hour? A 6-axis IMU sampling at 100 Hz with 16-bit samples produces about 4.3 MB per hour. An 8 MB buffer like the one in the DIDI.BIKE sensor can therefore store roughly 1.5-2 hours of complete ride telemetry.

What happens when the phone disconnects mid-ride? The sensor continues sampling and writes every data point to its internal flash buffer with a precise timestamp. When the phone reconnects, the buffered data is synced so the ride record has no gaps.

Why is an offline buffer important for cycling sensors? Bluetooth connections drop frequently on rides due to terrain, interference, and phone sleep. Without buffering, each drop creates a permanent hole in the ride data. A local buffer fills those gaps transparently.

Does offline buffering drain the battery faster? Flash writes add a modest amount of power consumption, but modern NAND flash is efficient. The DIDI.BIKE sensor still delivers 120 hours of battery life while continuously buffering when needed.

References

  1. IEEE Sensors Journal: Multi-sensor data fusion and attitude estimation using MEMS IMUs.
  2. Journal of NeuroEngineering and Rehabilitation: Wearable telemetry sensors and realtime posture tracking.
  3. DIDI.BIKE Technical Reprints: 100Hz IMU sampling rates and Kalman filtering for gravity extraction.
Baca panduan lengkap