This ESPHome configuration builds firmware that shows the heart rate sent by a Bluetooth Low Energy heart rate sensor on the display of an M5Stack Core or LilyGO TTGO T-Display ESP32.
This looks like this on an M5Stack Core:
And like this on a LilyGO TTGO T-Display ESP32:
And like this on a SH1106 1.3 inch OLED display:
- M5Stack Core, LilyGO TTGO T-Display ESP32 or a 1,3 inches SH1106 OLED display and an ESP32
- ESPHome 1.19.0 or later
- A heart rate sensor that implements the Heart Rate Measurement characteristic of Bluetooth Low Energy.
- This configuration doesn't enable Wi-Fi because the combination of the BLE client, display and Wi-Fi components uses too much memory, resulting in a boot loop. See issues #1336, #1731 and #2045.
- On older M5Stack Core models, the colors are inverted. See issue #1893. One solution is to copy the
ili9341
directory from your ESPHome installation's components directory and put it in a directorycustom_components
next to your YAML file. Then change the linethis->invert_display_(true);
in the filecustom_components/ili9341/ili9341_display.cpp
tothis->invert_display_(false);
. When compiling the firmware again, ESPHome uses your custom component instead of the default one.
There are three example configurations in this repository:
- m5stack_example.yaml for the M5Stack Core
- tdisplay_example.yaml for the TTGO T-Display ESP32
- SH1106_example.yaml for the OLED Display and an ESP32
Change the ble_mac
substitution to the BLE MAC address of your heart rate sensor and in case you are using the SH1106 OLED Display adapt the node_board
to your choice.
After this, flash the firmware to your device, e.g. with:
esphome run m5stack_example.yaml --device /dev/ttyUSB0
If you successfully created a configuration for another ESP32 board or another standalone display, please contribute an example configuration with a pull request.
ESPHome 1.18 added support for an ESP32 BLE Client and a BLE Sensor, which allows you to connect to Bluetooth Low Energy devices and read characteristics. This initial implementation was limited to one-byte characteristics which it interprets as float
values. But thanks to pull request #1851 (Add optional lambda to BLESensor for raw data parsing), you can also read the raw bytes, and this is available since ESPHome 1.19.
This ESPHome configuration makes use of these raw bytes in two ways (in common/heart_rate.yaml):
- Read the heart rate value from the second and third bytes of the Heart Rate Measurement characteristic (see the Heart Rate Service specification).
- Read the raw bytes of the Device Name characteristic and convert it to a string, which is published to a text sensor.
If you want to learn more about ESPHome, read my book Getting Started with ESPHome: Develop your own custom home automation devices and the accompanying GitHub repository koenvervloesem/Getting-Started-with-ESPHome.
This project is provided by Koen Vervloesem as open source software with the MIT license. See the LICENSE file for more information.
The included Roboto font is licensed under the Apache License, Version 2.0.
The C++/runtime codebase of the ESPHome project (file extensions .c, .cpp, .h, .hpp, .tcc, .ino) are published under the GPLv3 license. The Python codebase and all other parts of the ESPHome codebase are published under the MIT license. See the ESPHome License for more information.