The code in this repository acquires Peloton® Bike metrics (such as cadence and output) by using Tesseract OCR to perform digit recognition on the projected screen from the Android table installed on the bike.
Metrics are exposed at /metrics
REST endpoint so they can be consumed by a wide range of applications.
As an example, the code in this project can be used to integrate with zwack-bike to allow Peloton® Bike owners to take rides on Zwift.
Diagram of the project:
Clone repository, create virtual environment and install python dependencies:
git clone https://github.com/iaroslavn/peloton-bike-metrics-server.git
cd peloton-bike-metrics-server
virtualenv metrics-server-env
metrics-server-env\Scripts\activate.bat
pip install -r requirements.txt
Start the Peloton Bike Metrics Server:
cd peloton-bike-metrics-server
metrics-server-env\Scripts\activate.bat
set PATH=C:\Program Files\Tesseract-OCR\;%PATH%
python metrics-server.py
Open http://127.0.0.1:5000/metrics in your browser and verify that metrics are being returned. E.g.:
{"cadence": 85, "power": 102}
Use -d
or --debug
flag to start the server in the debug mode:
python metrics-server.py -d
Use -p
or --port
flag to change the default web server port:
python metrics-server.py --port 5001
get_power_and_cadence_imgs
function. Turn on the debug mode (-d
flag) to see what's been recognized by the OCR process.If you like this project, please consider doing the following: