- Bluetooth Low Energy Heart Rate Server#
- Bluetooth Low Energy Heart Rate Game
- Running the Example
- Visual Tour
- Bluetooth Low Energy and ANT+ heart rate monitor platform allows OEMs to modify and rebrand advanced fitness and movement tracking wearables
- Nordic’s nRF52832 multiprotocol SoC supports Cardiosport’s ‘TP5 Heart Rate Monitor’, enabling transmission of medical-grade heart rate and heart-beat interval data to sports/healthcare apps and devices
Bluetooth Low Energy Heart Rate Server#
The Bluetooth Low Energy Heart Rate Server is a command-line application that shows how to develop a Bluetooth GATT server using the Qt Bluetooth API. The application covers setting up a GATT service, advertising it and notifying clients about changes to characteristic values.
# Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause """PySide6 port of the bluetooth/heartrate-server example from Qt v6.x""" import sys from enum import Enum from PySide6.QtBluetooth import (QBluetoothUuid, QLowEnergyAdvertisingData, QLowEnergyAdvertisingParameters, QLowEnergyCharacteristic, QLowEnergyCharacteristicData, QLowEnergyController, QLowEnergyDescriptorData, QLowEnergyServiceData) from PySide6.QtGui import QGuiApplication from PySide6.QtCore import QByteArray, QTimer, QLoggingCategory class ValueChange(Enum): VALUE_UP = 1 VALUE_DOWN = 2 if __name__ == '__main__': app = QGuiApplication(sys.argv) QLoggingCategory.setFilterRules("qt.bluetooth* = true") #! [Advertising Data] advertising_data = QLowEnergyAdvertisingData() advertising_data.setDiscoverability(QLowEnergyAdvertisingData.DiscoverabilityGeneral) advertising_data.setIncludePowerLevel(True) advertising_data.setLocalName("HeartRateServer") advertising_data.setServices([QBluetoothUuid.ServiceClassUuid.HeartRate]) #! [Advertising Data] #! [Service Data] char_data = QLowEnergyCharacteristicData() char_data.setUuid(QBluetoothUuid.CharacteristicType.HeartRateMeasurement) char_data.setValue(QByteArray(2, 0)) char_data.setProperties(QLowEnergyCharacteristic.Notify) client_config = QLowEnergyDescriptorData(QBluetoothUuid.DescriptorType.ClientCharacteristicConfiguration, QByteArray(2, 0)) char_data.addDescriptor(client_config) service_data = QLowEnergyServiceData() service_data.setType(QLowEnergyServiceData.ServiceTypePrimary) service_data.setUuid(QBluetoothUuid.ServiceClassUuid.HeartRate) service_data.addCharacteristic(char_data) #! [Service Data] #! [Start Advertising] le_controller = QLowEnergyController.createPeripheral() service = le_controller.addService(service_data) le_controller.startAdvertising(QLowEnergyAdvertisingParameters(), advertising_data, advertising_data) #! [Start Advertising] #! [Provide Heartbeat] value_change = ValueChange.VALUE_UP heartbeat_timer = QTimer() current_heart_rate = 60 def heartbeat_provider(): global current_heart_rate, value_change, current_heart_rate value = QByteArray() value.append(chr(0)) # Flags that specify the format of the value. value.append(chr(current_heart_rate)) # Actual value. characteristic = service.characteristic(QBluetoothUuid.CharacteristicType.HeartRateMeasurement) assert(characteristic.isValid()) # Potentially causes notification. service.writeCharacteristic(characteristic, value) if current_heart_rate == 60: value_change = ValueChange.VALUE_UP elif current_heart_rate == 100: value_change = ValueChange.VALUE_DOWN if value_change == ValueChange.VALUE_UP: current_heart_rate += 1 else: current_heart_rate -= 1 heartbeat_timer.timeout.connect(heartbeat_provider) heartbeat_timer.start(1000) #! [Provide Heartbeat] def reconnect(): service = le_controller.addService(service_data) if not service.isNull(): le_controller.startAdvertising(QLowEnergyAdvertisingParameters(), advertising_data, advertising_data) le_controller.disconnected.connect(reconnect) sys.exit(app.exec())
Bluetooth Low Energy Heart Rate Game
A game demonstrating the interaction with a Bluetooth Low Energy Heart Rate device/service.
The Bluetooth Low Energy Heart Rate Game shows how to develop a Bluetooth Low Energy application using the Qt Bluetooth API. The application covers the scanning for Bluetooth Low Energy devices, connecting to a Heart Rate service on the device, writing characteristics and descriptors, and receiving updates from the device once the heart rate has changed.
The example introduces the following Qt classes:
A Bluetooth Low Energy device with a Heart Rate service is required for this application to work. An alternative might be a programmable Bluetooth Low Energy device which might simulate the service. You can also use the Heart Rate server example for that purpose. If no such device can be found, the example uses a demo mode which creates and displays random values.
The goal of the game is to increase the measured heart rate as much as possible.
The Bluetooth Low Energy Scanner example might be more suitable if a heart rate device is not available. The scanner example works with any type of Bluetooth Low Energy peripheral device.
Running the Example
To run the example from Qt Creator, open the Welcome mode and select the example from Examples. For more information, visit Building and Running an Example.
Visual Tour
The application searches for all Bluetooth Low Energy peripheral devices in the vicinity. It is assumed that the remote devices advertise their presence. The found devices are presented in a list. Note that all found Bluetooth Low Energy devices are listed even if they do not offer a Heart Rate service.
After the user has selected a target device, the example connects to its Heart Rate service if one is available. It automatically enables notification updates for the Heart Rate value and presents the current value on the screen.
Once the monitoring process is canceled, a small graph presents a summary of the received values.
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Bluetooth Low Energy and ANT+ heart rate monitor platform allows OEMs to modify and rebrand advanced fitness and movement tracking wearables
Nordic’s nRF52832 multiprotocol SoC supports Cardiosport’s ‘TP5 Heart Rate Monitor’, enabling transmission of medical-grade heart rate and heart-beat interval data to sports/healthcare apps and devices
Nordic Semiconductor today announces that Cardiosport, a Hampshire, U.K.-based OEM in the sports/healthcare industry, employs Nordic’s nRF52832 Bluetooth® Low Energy (Bluetooth LE) and ANT™ multiprotocol System-on-Chip (SoC) in its ‘TP5 Heart Rate Monitor’ (HRM).
TP5 is an advanced, customizable heart rate monitor platform designed to be modified, updated, and rebranded for fitness tracking and other applications/wearables in collaboration with a third-party OEM. The device features heart rate and movement sensors, along with a 3-axis accelerometer that can be programmed for running speed, pace, and cadence device profiles, as well as advanced running metrics like ground contact time, left/right leg balance and upper body position.
The integration of the Nordic SoC, which features a 2.4GHz multiprotocol radio supporting Bluetooth 5, ANT+, and proprietary 2.4GHz RF protocol software, allows the Cardiosport platform to transmit data via Bluetooth LE wireless connectivity to fitness apps hosted on Bluetooth 4.0 (and later) iOS and Android smartphones and tablets. The platform can simultaneously transmit data to ANT+ enabled devices such as smartwatches, bike computers, and fitness equipment.
The TP5 HRM uses a CR2032 coin cell battery to provide what Cardiosport describes as “industry-leading” battery life of 900+ hours, thanks in part to the ultra low power characteristics of the Nordic SoC. The nRF52832 has been engineered to minimize power consumption with features such as the 2.4GHz radio’s 5.5mA peak RX/TX currents and a fully-automatic power management system that reduces power consumption by up to 80 percent compared with Nordic’s nRF51 Series SoCs. Cardiosport also claims TP5 is one of the smallest and lightest HRMs on the market, with dimensions of 63 by 34 by 8.8mm and a weight of only 12g.
TP5 features a proprietary CBA9™ ECG ASIC chip for gathering extremely accurate heart rate data and r-r intervals (the time intervals between heart beats), thereby identifying individual heart beats during intense exercise, as well as meeting the requirements of medical ECG recorders.
We believe it is essential for heart rate monitor devices to incorporate support for Bluetooth LE, ANT+ and proprietary 2.4GHz protocols
The Cardiosport platform provides raw accelerometer data so developers are able to design apps around TP5’s functionality. For example, one Cardiosport customer uses the 3-axis accelerometer synched with the r-r intervals to monitor cardiovascular efficiency when the end user is running. Another customer integrates TP5 in clothing, through soft fabric ECG electrodes rather than a chest strap, to detect heart rate and r-r intervals in relation to the stillness and composure of the end user during yoga movements.
Programmable LED lights can be synched to the user’s heartbeat to change colour with HR zone, and display battery level and accelerometer movements. The LEDs offer up to nine different color configurations, while the functions can be changed for different TP5-based wearables via over-the-air device firmware updates (OTA-DFU).
Nordic’s nRF52832 multiprotocol SoC combines a 64MHz, 32-bit Arm® Cortex® M4F processor with the 2.4GHz multiprotocol radio featuring -96dB RX sensitivity, and generous 512kB Flash memory and 64kB RAM supporting complex applications and OTA-DFUs for Cardiosport customers.
The SoC is supplied with the S332 SoftDevice, a combination Bluetooth 5-certifed/ANT RF software protocol stack for building advanced Bluetooth LE and ANT applications. The S332 SoftDevice supports Central, Peripheral, Broadcaster and Observer Bluetooth LE roles, supports up to twenty connections, and enables concurrent role operation.
“We believe it is essential for heart rate monitor devices to incorporate support for Bluetooth LE, ANT+ and proprietary 2.4GHz protocols, which is one of the main reasons we selected the Nordic SoC,” says James MacGregor, Marketing and Business Development Manager at Cardiosport.
“Power consumption was also a very important factor when considering our choice of chip. The nRF52832 allows the TP5 Heart Rate Monitor to match the power consumption and battery life of Cardiosport’s previous TP3 Heart Rate Monitor, even though we have added LED lights, accelerometer/internal memory, and the ability to concurrently support Bluetooth LE & ANT+.
“Nordic’s nRF52 Series SoCs come with a lot of useful technical information, and the application engineers are always quick to respond to any queries,” adds MacGregor.