Heartbeat Monitor: fitness device built with Raspberry Pi
By Russell Barnes. Posted
One reader turned a Raspberry Pi into a fitness device by setting it up as a heartbeat monitor
Advertisement
Get started with Raspberry Pi – everything you need to know to start your journey!
The Raspberry Pi is increasingly being used in health applications – here’s how one maker made his own DIY Pi health device: Heartbeat Monitor.
You can tell a lot of things from a heartbeat, so Daniel Fernandez has decided to create his own heart tracker with help from a Raspberry Pi.
The current surge of smart watches, however long it lasts, probably owes something to the activity trackers that are synonymous with anyone trying to keep track of their fitness. These devices track the user’s heartbeat and use it to calculate things like periods of rest, calories burnt, and more.
This article first appeared in The MagPi Issue #55. Click here to download a free copy of The MagPi magazine.
Build a Heartbeat Monitor from a Raspberry Pi

“I have always liked to monitor my heartbeat while I run on the treadmill,” Daniel tells us. “There is simply no cheap, commercial solution that did everything I wanted: to plot the results in a graph that’s easy to monitor, so that you can look at them while you run, and then save the data so that you can work with it later. Furthermore, I wanted some flexibility in how the data was plotted and how often the heartbeat was updated, and to be able to retrieve the data from the device in an easy-to-process format like CSV.”
So began Daniel’s build. He selected the Raspberry Pi 3 as it was a fully fledged computer with built-in Bluetooth that could fit on his treadmill. He coupled it with a Polar H7 heart sensor and a 3.5˝ screen, and 3D-printed a little case to fit it all in.
“It’s not very difficult to build as most of the project is based on software,” explains Daniel. “If you have the sensor, screen, and software, you could have it working in less than a few hours. I have made the software open source and available via a GitHub repository.”
Using a Raspberry Pi fitness device
He’s been successfully using it for its intended purpose, having run 20 miles with it since he finished the project.
“So far, the Raspberry Pi has always worked correctly with my heartbeat sensor,” Daniel says. “The program has always provided smooth plots and a very responsive display of my real-time heartbeat. I have been able to save my run data files and perform some more extensive mathematical analysis to better understand how my heart reacts to changes in intensity, cadence, inclination, and so on.
- Starting up: When the Pi boots up, it loads up a Python script that checks the heartbeat data from the sensor, and a Free Pascal program that plots the data.

- Sending data: The heartbeat monitor automatically connects to the Pi and sends heartbeat data to the Python script. It’s saved to a text file, which is used to plot the results.

- Saved: A reset button on the display resets the plot and saves the on-screen data to a CSV file for analysis at a later date.

“I would want to include some functionality to save my heartbeat files to my Dropbox and even have the option to share the data on my social media accounts when I finish each run. I was also thinking about connecting the treadmill’s control panel to the Raspberry Pi so that the treadmill could adjust intensity automatically to match a target heartbeat.”
Other heartbeat sensors that follow the same standard as the Polar H7 should work with the project if you decide to make your own. Maybe it’s a good excuse to keep up with your New Year’s resolution?
Heartbeat Monitor facts
- It took two days for Daniel to develop the software
- Daniel wants to make an open-source voice assistant
- If you use the project, make sure the code launches at boot
- Daniel is an old hand with the Raspberry Pi, using it to automate several projects
- The case is to protect the Pi from sweat and spilt water
Russell runs Raspberry Pi Press, which includes The MagPi, Hello World, HackSpace magazine, and book projects. He’s a massive sci-fi bore.
Subscribe to Raspberry Pi Official Magazine
Save up to 37% off the cover price and get a FREE Raspberry Pi Pico 2 W with a subscription to Raspberry Pi Official Magazine.
More articles
Get started with Raspberry Pi in Raspberry Pi Official Magazine 161
There’s loads going on in this issue: first of all, how about using a capacitive touch board and Raspberry Pi 5 to turn a quilt into an input device? Nicola King shows you how. If you’re more into sawing and drilling than needlework, Jo Hinchliffe has built an underwater rover out of plastic piping and […]
Read more →
Win one of three DreamHAT+ radars!
That’s right, an actual working radar for your Raspberry Pi. We reviewed it a few months ago and have since been amazed at some of the projects that have used it, like last month’s motion sensor from the movie Aliens. Sound good? Well we have a few to give away, and you can enter below. […]
Read more →
RP2350 Pico W5 review
It’s Raspberry Pi Pico 2, but with a lot more memory
Read more →