OpenHRStrap: an open ESP32 ECG chest strap that runs Pan-Tompkins and streams BLE heart rate
A commercial chest strap from Polar or Garmin costs several hundred dollars on the promise that a skin-contact electrode beats the optical sensor on your wrist. The open-source OpenHRStrap project builds the same idea from parts you can buy, then hands you the whole schematic, the firmware, and the recorded data.
OpenHRStrap is built around an ESP32 XIAO S3 board paired with an AD8232 ECG analog front end. Electrodes on the strap pick up the faint electrical signal of the heart, the AD8232 conditions it, and the ESP32 runs the Pan-Tompkins detector to find R-peaks and turn them into a heart rate. The author, Milos Rasic, released it under the MIT license, so the hardware and the code are free to study and rebuild.
Why a strap reads differently from a watch
A wrist device estimates heart rate from photoplethysmography, shining light into the skin and watching how much bounces back as blood volume changes. A chest strap instead measures the electrocardiogram directly: the small voltage spikes the heart produces each beat. The two approaches disagree most when you move, which is exactly when athletes care about the number. OpenHRStrap is an attempt to put a real ECG front end, not a pulse-ox clone, into a strap you can assemble yourself.
The signal chain
The AD8232 does the hard analog work. It is the most common breakout for ECG because it packages the instrumentation amplifier, the right-leg drive, and the leads-off detection that a dry-electrode strap needs. Its output feeds the ESP32, which samples the waveform and runs the detection algorithm. Power comes from a single-cell Li-ion cell stepped up to 5 V, with a slide switch and a 3D-printed shell in PLA and TPU.
Pan-Tompkins, the 1985 detector
The detection method is the Pan-Tompkins algorithm from the 1985 paper A Real-Time QRS Detection Algorithm by Jiapu Pan and Willis J. Tompkins. It is the reference method for QRS detection, and the project implements it in Python following the original filter chain. The pipeline is straightforward to read but careful in the details:
- Band-pass filtering, a low-pass stage plus a high-pass stage, removes baseline wander and muscle noise.
- Differentiation amplifies the steep slope of the QRS complex.
- Squaring suppresses low-amplitude noise and emphasizes the peaks.
- A moving-window integrator draws out the envelope of the waveform.
The detector keeps two running thresholds, TH1 and TH2, updated from estimates of the signal peak and the noise peak. A peak on the integrated signal that clears TH1 is confirmed only if the corresponding filtered peak meets a second condition, otherwise it is counted as noise. The part that makes the method robust is the search-back rule: if no R-peak is found within 1.66 times the average RR interval, the algorithm drops to the lower threshold TH2 and rescans, recovering peaks it would otherwise have missed. The details matter, and the author drew a hand sketch of the whole threshold logic.
The author tested the Python implementation on more than 80 seconds of pre-recorded resting data and missed about one R-peak, with the first 10 seconds spent on parameter initialization. That result describes resting data, not a run, and the project is open that it does not yet represent real-time running accuracy.
A standard BLE heart rate service
The firmware does not invent a private protocol. It advertises as a standard Bluetooth Low Energy heart rate monitor, using the Bluetooth SIG Heart Rate Service 0x180D with the Heart Rate Measurement characteristic 0x2A37, so any app that already supports a commercial strap can read it. The device appears to phones as an off-the-shelf sensor, which the author demonstrated pairing with Strava. Whether a given app accepts the connection still depends on that app's peripheral compatibility policy, so universal support is not guaranteed.
V1 hardware and what V2 changes
The current version is deliberately friendly to replicate. It is built from common modules: the XIAO ESP32 board, the AD8232 module, a button-cell reference electrode sewn into the strap, a 1S Li-ion cell, and a 5 V boost board. The schematic is published, and the layout sketch shows where each module and the strap electrodes sit.
| Aspect | V1 | V2 (in progress) |
|---|---|---|
| Form | Off-the-shelf modules | Custom PCB |
| Shell | 3D-printed PLA and TPU | Revised enclosure |
| Data logging | None on device | Planned, proper logging |
| Analog front end | AD8232 breakout | Upgraded AFE |
V2 is listed as in progress. The plan is a custom board with proper data logging and an upgraded analog front end, and the author has opened a call for input on what to include.
What the tests show, and what they do not
The most honest part of the write-up is the field test. The author ran 5 kilometers wearing the strap and a PPG wrist watch as a reference, exported the watch data from Strava, and analyzed both with Python scripts that are also in the repository. Early in the run the two tracks sat close together; as heart rate climbed the gap widened, and on the whole the DIY device reported lower. The author's own read is that V1 has no data-logging, so there is no record of what the algorithm actually did during the run, only a guess at the cause. That gap is exactly what V2's logging is meant to close.
The author is explicit that the project is for education, experiment, and hobby only. The repository carries a disclaimer stating the device is not a medical device, is not certified, and must not be used for diagnosis, monitoring of medical conditions, or any health-critical purpose. The software and hardware are provided as-is.
Where it fits
For someone who wants to understand ECG acquisition and the Pan-Tompkins method rather than just buy a number, OpenHRStrap is a strong starting point. The schematic, the code, and the recorded data are all in the repository, and the bill of materials is cheap enough to build from. The 2025 update also added a simpler build that pairs the XIAO board with the AD8232 module directly, with the static-data Pan-Tompkins performance already good and the running-time detection still being refined. The project was also shared on the element14 community.