STM32WB Bluetooth® LE – Heart Rate Sensor Project

Revision as of 16:50, 28 January 2022 by Registered User (→‎Hardware requirements)

1. Heart Rate Profile Presentation

Heart Rate Profile (HRP) [1] is a Generic Attribute Profile (GATT) based low energy profile defined by the Bluetooth® Special Interest Group[2]
The HRP, widely used in fitness applications, defines the communication between a GATT-server of a Heart Rate Sensor device, such as a wrist band, and a GATT-client Collector device, such as a smartphone or tablet.
Heart Rate Sensor is the device that measures heart rate data and other information, it can be defined as a GAP peripheral and GATT server implemented with the Heart Rate Service [3]

This wiki page is the description of the Heart Rate Sensor project provided within the STM32CubeWB MCU Package[4]

Bluetooth® LE Heart Rate profile overview
Connectivity Heart-Rate-Profile-Overview.png


2. Heart Rate Profile Interaction

2.1. GAP - Generic Access Profile

Defines and manages advertising and connection : Connectivity HR GAP Interaction.png

2.2. GATT - Generic Attribute Profile

Defines and manages in/out data exchanges :

Connectivity HR GATT Interaction.png

Once Bluetooth® LE connection established & notification enabled :

  • Heart Rate measurement provided to remote every 1s.
  • Connection interval may be change by application.

3. Requirements

3.1. Software and System requirements

Software required are the following:
minimum IDEs version:

  • IAR Embedded Workbench for ARM (EWARM) toolchain V8.20.2
  • RealView Microcontroller Development Kit (MDK-ARM) toolchain V5.31
  • STM32CubeIDE toolchain V1.7.0 [5].


Programmer:

  • STM32CubeProgrammer[6] : To flash the board with an already generated binary

3.2. Hardware requirements

P-NUCLEO-WB55 [7] or STM32WB5MM-DK Discovery Kit [8] is necessary to install the application.

Hardware platforms illustration
Connectivity hardware-presentation.png


Plus a smartphone with ST BLE Sensor application (for Android[9], or iOS[10]).

3.3. Smartphone Application

4. STM32WB Heart Rate Sensor Example Description

4.1. Project Directory

The "BLE_HeartRate" application is available by downloading STM32CubeWB MCU Package[11].

Heart Rate project directory
Connectivity heartRate.png

4.2. Project Description

4.2.1. Structure

Software project structure with the most important parts :

Connectivity HR project structure.png


Connectivity yellow box.png
Main applicative part files
Connectivity blue box.png
Bluetooth® LE Stack API Interface
Connectivity dark blue box.png
Services management
Connectivity green box.png
System commands
Connectivity pink box.png
Transport Layer Interface

WARNING: Do not modify the files in Middlewares folder

4.2.2. Application Initialization

The different steps of application initialization are described bellow :

Connectivity HR Application Initialization.png
puce1.png
  • Initialize the system (HAL, Clock, Power Mode, RTC IP, Timer Server)
  • Infinite loop for run mode
puce2.png
  • Initialize the BSP (LEDs, buttons…), Transport Layer Interface, Debugger
  • Wait for initialization done
puce3.png
  • Initialize the Bluetooth® LE App – GAP level
  • Manage GAP events (advertising,scanning)
puce4.png
  • Initialize the Bluetooth® LE App – GATT level
  • Initialize the Bluetooth® LE Stack
  • Manage GATT events
puce5.png
  • Initialize services
  • Manage services

4.2.3. GAP & GATT Initialization & Interaction

Interaction between Middleware and User Application is described in the following illustration. lionel to explain...

Heart Rate project architecture
Connectivity HeartRate-Project.png


4.3. Build and Install

Follow steps described in Bluetooth® LE Build and Install Application page, applying it for BLE_HeartRate project.

5. Heart Rate Collector - Smartphone Application

Once the BLE Heart Rate application installed on the STM32WB platform, launch the ST BLE Sensor smartphone application.

Click on Connect one Device interface:

Heart Rate application interface 1
Connectivity Heart-Rate-screen-cap-1.jpg


Your device should be visible from this interface, connect to it:

Heart Rate application interface 2
Connectivity Heart-Rate-application-2.jpg


Now bpm measurement is displayed in real time.

Heart Rate application interface 3
Connectivity Heart-Rate-App-3.jpg


With Discovery Kit Platform, the Heart Rate is also visible from the board LCD screen, and Heart pulse is illustrated:

Heart Rate on DK illustration
Connectivity heart-rate-DK.png

6. References