Live heart rate for remote training

A Fitbit band streams my heart rate, and my online trainer sees zones and points live, Orangetheory style.

// 0x2A37: bit 0 says how wide the reading is
const flags = view.getUint8(0);
const bpm = flags & 0x01
  ? view.getUint16(1, true)
  : view.getUint8(1);

channel.send({
  type: "broadcast",
  event: "hr",
  payload: { seq: ++seq, bpm },
});
Band to trainer, simplified.
When
2026
Status
Working, in progress
Code
Private repository
Stack
Web Bluetooth, Supabase Realtime, Postgres RLS, JavaScript, Node test runner

From a wristband to a remote screen

  1. Bluetooth in the browser

    Reads the standard heart-rate characteristic, 0x2A37, straight from the band.

  2. A two-way realtime protocol

    hr, ack, plan, hello and ended events; echoed sequence numbers measure round trips.

  3. One writer

    Only the athlete page writes: 10 s batches with retry and idempotent upserts.

  4. Tested end to end

    A test drives both pages with a fake band over the DevTools Protocol.