Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pm5-hid

Web-based monitor for the Concept2 PM5 using the Web HID API.

Requirements

  • Chrome or Edge (Web HID is not supported in Firefox or Safari)
  • PM5 connected via USB

Usage

Open index.html in Chrome or Edge, click Connect, and select the PM5 from the browser's device picker.

pm5hid.js

PM5HID is a standalone ES2020+ class (extends EventTarget) that communicates with the PM5 over USB HID using the CSAFE protocol.

const monitor = new PM5HID();

monitor.addEventListener('connected',    e => console.log(e.data)); // { model, firmwareVersion, serial }
monitor.addEventListener('workout',      e => console.log(e.data)); // see Workout event below
monitor.addEventListener('stroke',       e => console.log(e.data)); // see Stroke event below
monitor.addEventListener('disconnected', () => { });

await monitor.connect(); // prompts the browser's HID device picker
monitor.disconnect();
monitor.connected();     // → boolean

Events

Event data properties
connecting
connected model, firmwareVersion, serial
disconnected
workout status, workTime, workDistance, pace, power, calories, cadence, heartRate, dragFactor, workoutType, workoutState
stroke power, strokeState

Polling

The library polls the PM5 at 100 ms intervals. A stroke frame (power + stroke state) is sent every tick; a full workout frame is sent every 5th tick (500 ms). Machine info (version, serial number) is queried once on connect before the poll loop starts.

Protocol

The PM5 uses CSAFE over HID report ID 0x02 with a 120-byte payload. Frames are bounded by 0xf1 (start) and 0xf2 (stop) flags; bytes in the 0xf0–0xf3 range within the payload are byte-stuffed. A single XOR checksum byte is appended to the payload before stuffing.

See also

About

Connecting to a Concept2 PM5 monitor over USB using HID.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages