Efficient Design of BLE 5.3 Health Thermometer Sensor Using Wireless MCU

Author:Jens Wallmann

Abstract:This article introduces the ultra-low power STM32WBA52 MCU series from STMicroelectronics, demonstrating how developers can quickly complete and run BLE 5.3 wireless designs using BLE evaluation boards, development tools, and application examples. Additionally, this article briefly discusses programming and MCU wiring.

Intense competition puts pressure on Internet of Things (IoT) device developers, who must rapidly launch new innovative products while also reducing costs and ensuring stable, low-power, and secure communication. Traditional smart IoT endpoints include microcontroller units (MCUs) for edge processing and wireless integrated circuits for connectivity. Problems arise when design teams lack the necessary radio frequency (RF) skills to develop effective solutions.

To complete and certify wireless IoT designs on time and bring them to mass production, developers must enhance the efficiency of the development process. One way to improve development process efficiency is to use low-power MCUs equipped with integrated low-power Bluetooth (BLE) wireless interfaces.

This article introduces the ultra-low power STM32WBA52 MCU series from STMicroelectronics, demonstrating how developers can quickly complete and run BLE 5.3 wireless designs using BLE evaluation boards, development tools, and application examples. Additionally, this article briefly discusses programming and MCU wiring.

Energy-Efficient Wireless MCU with High Security Levels

The STM32WBA52 MCU series has been certified for BLE 5.3, providing a cost-effective solution that helps novice developers quickly add wireless communication capabilities to their devices. These microcontrollers are based on the Arm® Cortex®-M33 core with a clock frequency of 100 MHz and TrustZone technology, offering high security to protect data and intellectual property (IP) against hacking and device cloning.

The STM32WBA52CEU6 wireless MCU features 512 KB of flash memory and 96 KB of static RAM (SRAM), while the STM32WBA52CGU6 model features 1 MB of flash memory and 128 KB of SRAM. Figure 1 shows the functional range of the integrated circuit in a 48 UFQFN package. Additionally, up to 20 capacitive touch channels support the operation of sealed devices (without mechanical buttons).

Efficient Design of BLE 5.3 Health Thermometer Sensor Using Wireless MCU

Figure 1: Functional block diagram of the STM32WBA52 showing the integrated BLE 5.3 radio, flash memory, and SRAM, along with security support. (Image source: STMicroelectronics)

The rich STM32Cube ecosystem supports the implementation and programming of BLE applications. This ecosystem includes the STM32CubeIDE development environment and various tools, such as the STM32CubeMX peripheral configurator and code generator, STM32CubeMonitorRF performance tester, and the desktop and cloud versions of STM32Cube.AI for artificial intelligence (AI). The matching evaluation board NUCLEO-WBA52CG simplifies prototyping and provides numerous BLE instance applications and free source code to accelerate validation.

Device and Data Security

The STM32WBA52 product series has achieved a platform security architecture (PSA) certification level 3 and a security assurance level 3 (SESIP3) according to IoT security standards. The PSA security certification program, based on security isolation, memory protection, and tamper protection, along with the Arm TrustZone architecture of the MCU Cortex-M33, enhances network protection. The Trusted Firmware (TF-M) for Arm Cortex-M complies with the industry-standard PSA certified security framework, including a PSA immutable root of trust (RoT), secure boot, and secure firmware updates(X-CUBE-SBSFU), encryption, secure storage, and runtime validation.

Integrated Radio Minimizing Material Costs

The integrated ultra-low power radio module offers +10 dBm (decibel referenced to 1 mW) of RF output power. This module enables reliable communication over short distances (BLE 5.3) and long distances (Long Range), with data transmission rates of up to 2 Mbps. During radio communication, the deep sleep low power mode can reduce overall power consumption. The STM32WBA MCU can support up to 20 simultaneous connections.

The electrical performance characteristics of the radio module include:

· Supporting BLE 5.3 2.4 GHz RF transceiver
· Receiving sensitivity: -96 dBm (1 Mbps BLE)
· Programmable output power, up to +10 dBm, in 1 dB steps

· Integrated balun

Smaller Battery Size Due to Efficient Energy Management

The STM32WBA52 MCU employs multiple energy-saving technologies, including STMicroelectronics’ low-power direct memory access (LPDMA) and flexible power-saving states with fast wake-up times. These features combine to reduce MCU power consumption by up to 90%, significantly shrinking battery size or extending battery life.

The electrical performance characteristics of FlexPowerControl include:

· 1.71 to 3.6 V power supply
· 140 nA standby mode (16 wake-up pins)
· 200 nA standby mode with real-time clock (RTC) running
· 2.4 μA standby mode with 64 KB SRAM
· 16.3 μA stop mode with 64 KB SRAM
· 45 μA/MHz running mode at 3.3 V

· Radio: Rx 7.4 mA/Tx, 0 dBm, 10.6 mA

Additionally, Bluetooth 5.3 switches faster between low duty cycle and high duty cycle, resulting in higher energy efficiency than previous versions.

Bluetooth Stack Architecture and Packets

The single-core Arm Cortex-M33 MCU in the STM32WBA52 is dedicated to application firmware development, including profiles and services on the BLE stack (controller and host). The MCU handles data flow from the integrated RF module at the lowest physical layer (PHY) to the Generic Attribute Profile (GATT) and Generic Access Profile (GAP) (Figure 2). GAP defines and manages broadcasting and connections, while GATT defines and manages the exchange of data in and out.

Efficient Design of BLE 5.3 Health Thermometer Sensor Using Wireless MCU

Figure 2: The MCU handles data flow from the radio PHY to GATT and GAP. (Image source: STMicroelectronics)

Packets sent via BLE are defined as a fixed frame structure of a bit sequence. The length of the user data area dynamically varies between 27 to 251 bytes.

BLE Application Examples

The section on STM32WBA MCU in the online encyclopedia STMicro-Wiki contains multiple application examples with different Bluetooth roles, including:
· Broadcast: BLE_Beacon
· Sensor: BLE_HealthThermometer, BLE_HeartRate
· Bridge: BLE_SerialCom
· Router: BLE_p2pRouter
· Data: BLE_DataThroughput, BLE_p2pServer, and Multi Slave BLE_p2pClient
· RF Monitor: BLE_TransparentMode

· Firmware Over-the-Air Upgrade: BLE_Fuota

Device designers and programmers can burn the corresponding compiled binaries from the GitHub project directory to the NUCLEO development board based on their BLE projects and then initiate a Bluetooth connection with a smartphone or desktop computer. The required programmer software STM32CubeProg allows users to read, write, and verify device memory through the debug interface and bootloader interface.

Running the BLE Instance “Health Thermometer Sensor”

The Health Thermometer Profile (HTP) is a low-power specification based on GAP established by the Bluetooth Special Interest Group (SIG). It combines health thermometer collectors and health thermometer sensors to connect and exchange data in various applications (Figure 3).

Efficient Design of BLE 5.3 Health Thermometer Sensor Using Wireless MCU

Figure 3: BLE communication between the NUCLEO development board acting as a sensor/server and a smartphone acting as a collector/client. (Image source: STMicroelectronics)

Health thermometer sensor:

· Measures temperature and publishes data via the health thermometer service
· Contains device information service for remote devices to identify

· Acts as a GATT server

Health thermometer collector:
· Accesses information provided by the health thermometer sensor and displays it to the end user or stores it in non-volatile memory for later analysis

· Acts as a GATT client

After burning the health thermometer binary file to the NUCLEO’s MCU, developers need to follow these steps to run the BLE application instance:

Using Smartphone Application

1. Install the ST BLE Toolbox on the smartphone. This application is used to interact with and debug ST BLE devices.

2. Power on the STM32WBA NUCLEO development board with the burned health thermometer application.

3. Open Bluetooth on the smartphone (BT), scan for available Bluetooth devices in the application. Select the health thermometer and connect.

Using Web Browser Interface

1. Ensure browser compatibility:
o On desktop: Chrome, Edge, or Opera
o On smartphone devices: Android Chrome browser
2. Power on the STM32WBA NUCLEO development board with the burned health thermometer application.
3. Activate Bluetooth on the computer.
4. Open the webpage https://applible.github.io/Web_Bluetooth_App_WBA/.
5. Click the connect button at the top of the webpage, then select HT_xx from the device list and click pair. The device is now connected.

6. Click on the health thermometer to display the interface.

Table 1 shows the service structure of the health thermometer sensor. The 128-bit globally unique identifier (UUID) distinguishes various characteristics and services.

Service

Characteristic

Property

UUID

Size

Health Thermometer Service

0X1809

Temperature Measurement

Indicate

0x2A1C

13

Temperature Type

Read

0x2A1D

1

Intermediate Temperature

Notify

0x2A1E

13

Measurement Interval

Read, Write, Indicate

0x2A21

2

Device Information Service

0X180A

Manufacturer Name String

Read

0x2A29

32

Model Number String

Read

0x2A24

32

System ID

Read

0x2A23

8

Table 1: GATT services of the “Health Thermometer Sensor” and their UUIDs. (Image source: STMicroelectronics)

The following JavaScript sequence from GitHub shows how the web browser interface filters different GATT data throughput characteristics (Listing 1).

Copy[…]// Filtering the different datathroughput characteristics props.allCharacteristics.map(element => { switch (element.characteristic.uuid) { case “00002a1c-0000-1000-8000-00805f9b34fb”: IndicateCharacteristic = element; // Temperature Measurement (TEMM) IndicateCharacteristic.characteristic.startNotifications(); IndicateCharacteristic.characteristic.oncharacteristicvaluechanged = temperatureMeasurement; break; case “00002a1d-0000-1000-8000-00805f9b34fb”: ReadCharacteristic = element; // Temperature Type readTemperatureType(); break; case “00002a1e-0000-1000-8000-00805f9b34fb”: NotifyCharacteristic = element; //Immediate Temperature NotifyCharacteristic.characteristic.startNotifications(); NotifyCharacteristic.characteristic.oncharacteristicvaluechanged = notifHandler; break; case “00002a21-0000-1000-8000-00805f9b34fb”: ReadWriteIndicateCharacteristic = element; // Measurement Interval readMeasurementInterval(); break; default: console.log(“# No characteristics found..”); } });[…]

Listing 1: This JavaScript sequence filters different GATT data throughput characteristics in Table 1. (Listing source: GitHub, STMicroelectronics)

Tracking BLE Stack Processes

The NUCLEO-WBA52CG is embedded with the ST-LINK/V3 online debugger and programmer, supporting the STM32 virtual COM port driver for communication with a PC via serial interface. Any software terminal can open this serial communication port to display text short messages generated by the APP_DBG_MSG function in the code.

Tracking within the project requires enabling in the app_conf.h file

#define CFG_DEBUG_APP_TRACE (1)

Additionally, the smartphone application “SE BLE Toolbox” provides tracing capabilities under the <Application Log> tab.

BLE 5.3 Application Programming

To program the STM32WBA52 MCU, ST has launched the STM32CubeWBA software package, consisting of a hardware abstraction layer (HAL), low-layer application programming interface (API), CMSIS, file system, RTOS, BLE/802.15.4, Thread, and Zigbee stacks, along with instances running on STMicroelectronics boards.

Each NUCLEO-WBA52CG BLE application instance includes project structure setups suitable for all three development environments (IDE) such as IAR Embedded Workbench for Arm (EWARM), Keil MDK-ARM, and STM32CubeIDE.

In the health thermometer instance, only specific files in the project directory tree (Figure 4 left frame) will generate the GATT services. The two routines “Health Thermometer Service” (hts) and “Device Information Service” (dis) run in parallel (Figure 4 bottom right).

Efficient Design of BLE 5.3 Health Thermometer Sensor Using Wireless MCU

Figure 4: Programmers can add their GATT content in the framework code files (left); these files generate GATT services (right). (Image source: STMicroelectronics)

Programmers can use the source code for their own projects and extend the area marked USER CODE BEGIN/USER CODE END to add their GATT content (Listing 2). The initialization sequence in the file hts.c generates the GATT characteristic temperature measurement (TEMM), which has a UUID of 0x2A1C.

Copy[…] void HTS_Init(void) { […] /* TEMM, Temperature Measurement */ uuid.Char_UUID_16 = 0x2a1c; ret = aci_gatt_add_char(HTS_Context.HtsSvcHdle, UUID_TYPE_16, (Char_UUID_t *) &uuid, SizeTemm, CHAR_PROP_INDICATE, ATTR_PERMISSION_NONE, GATT_DONT_NOTIFY_EVENTS, 0x10, CHAR_VALUE_LEN_VARIABLE, &(HTS_Context.TemmCharHdle)); if (ret != BLE_STATUS_SUCCESS) { APP_DBG_MSG(” Fail : aci_gatt_add_char command : TEMM, error code: 0x%2X\n”, ret); } else { APP_DBG_MSG(” Success: aci_gatt_add_char command : TEMM\n”); } /* USER CODE BEGIN SVCCTL_InitService2Char1 */ /* USER CODE END SVCCTL_InitService2Char1 */ […] }[…]

Listing 2: The initialization sequence in the file hts.c generates the GATT characteristic TEMM. (Image source: GitHub, STMicroelectronics)

External Component Requirements

The STM32WBA52 wireless MCU requires only a few external components to achieve basic Bluetooth functionality. These components include capacitors for voltage supply, crystal oscillators, printed circuit board antennas with impedance matching, and harmonic filters (Figure 5).

Efficient Design of BLE 5.3 Health Thermometer Sensor Using Wireless MCU

Figure 5: The RF terminals of the STM32WBA52 are connected to the impedance matching network, harmonic filter, and antenna to achieve Bluetooth functionality. (Image source: STMicroelectronics)

Conclusion

Wireless IoT device developers must shorten design cycles and reduce costs to compete in a rapidly evolving market. However, RF design is very challenging. The STM32WBA52 MCU integrates a BLE 5.3 interface, enabling developers to rapidly and cost-effectively bring products to market. The pre-programmed BLE stack and multiple BLE application instances provide programming templates for customized projects, allowing easy insertion of GATT content.

Editor’s Note

As the latest version of Bluetooth technology, BLE 5.3 faces a series of challenges in design and implementation, such as power optimization, connection management, security, handling multiplexing, and broadcasting. To address these challenges, system designers need to comprehensively consider hardware, software, and protocol stack designs to optimize the overall system performance and stability. The MCU series mentioned in this article provides an excellent choice to address these pain points. What challenges have you encountered in designing BLE 5.3 systems? What considerations do you have when selecting a wireless MCU? Feel free to leave comments and share!

Efficient Design of BLE 5.3 Health Thermometer Sensor Using Wireless MCU

Leave a Comment