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
Head to head: Raspberry Pi + Raspberry Pi Zero + Raspberry Pi Pico.
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

Raspberry Pi vs Raspberry Pi Zero 2 vs Raspberry Pi Pico in Raspberry Pi Official Magazine 159
Without an operating system, any computer – including your Raspberry Pi – is just a dumb lump of sand. Put Raspberry Pi OS on it however, and you’ve got yourself a working system that can handle games, web browsers, emails, programming and everything else we bang on about here all day every day. The latest […]
Read more →

Win one of ten M.2 HAT+ Compact
The ability to connect NVME SSD drives to Raspberry Pi 5 is very cool, although it does slightly limit the cases you can use. With the M.2 HAT+ Compact, you can even fit an SSD-powered Raspberry Pi into the official case – and we have ten to give away below. Win one of ten M.2 […]
Read more →

Raspberry Pi 500+ in Raspberry Pi Official Magazine issue 158
We’re quite taken with Raspberry Pi 500+. But when you don’t need all that processing power, and just want a board that will make a plastic skeleton jump around in a terrifying manner, you’ll find Raspberry Pi Pico more than up to the job. There’s more terror in the magazine (which is only right as […]
Read more →
Sign up to the newsletter
Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.