This Arduino sketch shows the heart rate sent by a Bluetooth Low Energy heart rate sensor on the display of an M5Stack Core 2.
This is a proof of concept with basic functionality. It supports any heart rate sensor that implements the Heart Rate Measurement characteristic of Bluetooth Low Energy.
- Prepare your Arduino IDE for the M5Stack Core2.
- Install the Core2ez library as a ZIP file.
- Install the M5Core2 and NimBLE-Arduino libraries from the library manager.
There's a Makefile to ease the installation of the platform and libraries if you are using arduino-cli:
make platform
make libraries
Then you can build the sketch:
make build
After this, you can upload the binary firmware file to your M5Stack Core2:
arduino-cli upload -p /dev/ttyUSB0 -b m5stack:esp32:m5stack-core2 -i $PWD/build/M5Core2-Heart-Rate-Display.ino.bin
- Improve the user interface.
- Let the user choose the heart rate sensor to connect with.
- Send heart rate measurements to MQTT for further processing and visualization.
If you want to learn more about Bluetooth Low Energy development, read my book Develop your own Bluetooth Low Energy Applications for Raspberry Pi, ESP32 and nRF52 with Python, Arduino and Zephyr and the accompanying GitHub repository koenvervloesem/bluetooth-low-energy-applications.
This project is provided by Koen Vervloesem as open source software with the MIT license. See the LICENSE file for more information.
The source code is based on h2zero's NimBLE_Client.ino example from the NimBLE-Arduino library.