Efficient! Using This Wireless MCU to Design a BLE 5.3 Health Thermometer Sensor!

The intense competition has put pressure on IoT (IoT) device developers, who must quickly launch new innovative products while also reducing costs, ensuring stable, low-power, and secure communication. Traditional smart IoT terminal nodes include microcontroller units (MCU) for edge processing and wireless integrated circuits for connectivity. Problems arise when design teams lack the RF(RF) skills necessary to develop effective solutions.
To complete and certify wireless IoT designs on time and bring them to mass production, developers must improve the efficiency of the development process. One way to enhance the efficiency of the development process 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 and demonstrates 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 covers programming and MCU wiring.
Energy-efficient Wireless MCU with High Security Levels
The STM32WBA52 MCU series has been certified for BLE 5.3, offering a cost-effective solution to help novice developers quickly add wireless communication capabilities to their devices. These microcontrollers are based on an Arm® Cortex®-M33 core with a clock frequency of 100 MHz and TrustZone technology, providing high security to protect data and intellectual property (IP) against hacking and device cloning.
STM32WBA52CEU6 Wireless MCU features 512 KB of flash memory and 96 KB of static RAM (SRAM), whereas the STM32WBA52CGU6 model comes with 1 MB of flash memory and 128 KB of SRAM. Figure 1 shows the functional scope of the integrated circuit in a 48 UFQFN package. Additionally, up to 20 capacitive touch channels can support the operation of sealed devices (without mechanical buttons).
Efficient! Using This Wireless MCU to Design a BLE 5.3 Health Thermometer Sensor!
Figure 1: The functional block diagram of the STM32WBA52 shows the integrated BLE 5.3 radio, flash memory, SRAM, and 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 STM32Cube.AI desktop and cloud versions for artificial intelligence (AI). The matching evaluation board NUCLEO-WBA52CG simplifies prototype design and provides a wealth of BLE example applications and free source code to accelerate validation.
Device and Data Security
The STM32WBA52 product series meets the IoT security standards of Platform Security Architecture (PSA) certification level 3 and the IoT Platform Security Evaluation Standard Guarantee Level 3 (SESIP3). The PSA security certification program based on security isolation, memory protection, and tamper protection, along with the Arm TrustZone architecture of the Cortex-M33 MCU, enhances network protection. The Trusted Firmware (TF-M) for Arm Cortex-M complies with the industry-standard PSA-certified security framework, which includes a PSA immutable root of trust (RoT), secure boot, and secure firmware updates (X-CUBE-SBSFU), encryption, secure storage, and runtime verification.
Integrated Radio Minimizes Material Costs
The integrated ultra-low-power radio module provides +10 dBm (decibels 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 this radio module are:
  • 2.4 GHz RF transceiver supporting BLE 5.3
  • Receive sensitivity: -96 dBm (1 Mbps BLE)
  • Programmable output power, up to +10 dBm, with a step size of 1 dB
  • 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 low-power 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.
Electrical performance characteristics of FlexPowerControl:
  • 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 run mode at 3.3 V
  • Radio: Rx 7.4 mA/Tx, 0 dBm, 10.6 mA
Furthermore, Bluetooth 5.3 features faster switching speeds between low duty cycle and high duty cycle, resulting in improved energy efficiency compared to previous versions.
Bluetooth Stack Architecture and Packets
The single-core Arm Cortex-M33 MCU in the STM32WBA52 is specifically designed for 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 data exchange in and out.
Efficient! Using This Wireless MCU to Design a BLE 5.3 Health Thermometer Sensor!
Figure 2: The MCU processes data flow from the radio PHY to GATT and GAP. (Image source: STMicroelectronics)
The packets sent via BLE are defined by a fixed frame structure of bit sequences. The length of the user data area varies dynamically between 27 and 251 bytes.
BLE Application Examples
The STMicro-Wiki encyclopedia section on the STM32WBA MCU 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 flash the compiled binaries from the corresponding GitHub project directory to the NUCLEO development board based on their BLE project, and then initiate Bluetooth connections with smartphones or desktop computers. The required programming software STM32CubeProg allows users to read, write, and verify device memory through debug and bootloader interfaces.
Running the BLE Instance “Health Thermometer Sensor”
The Health Thermometer Profile (HTP) is a GAP-based low-power specification established by the Bluetooth Special Interest Group (SIG). It combines a health thermometer collector and a health thermometer sensor to connect and exchange data across different applications (Figure 3).
Efficient! Using This Wireless MCU to Design a BLE 5.3 Health Thermometer Sensor!
Figure 3: BLE communication between the NUCLEO development board as a sensor/server and a smartphone as a collector/client. (Image source: STMicroelectronics)
Health Thermometer Sensor:
  • Measures temperature and publishes data via the health thermometer service

  • Includes 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 flashing the health thermometer binary to the NUCLEO MCU, developers need to follow these steps to run the BLE application instance:

Using a 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 flashed health thermometer application.
  3. Turn on Bluetooth (BT) on the smartphone, scan for available Bluetooth devices in the application, select the health thermometer, and connect.

Using the Web Browser Interface

1. Ensure browser compatibility:
  • On desktop: Chrome, Edge, or Opera
  • On smartphone: Android version of Chrome browser

2. Power on the STM32WBA NUCLEO development board with the flashed 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 individual characteristics and services.
Service
Characteristic
Attribute
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 and their UUIDs for the “Health Thermometer Sensor” GAP. (Image source: STMicroelectronics)
The following JavaScript sequence from GitHub shows how to filter different GATT data throughput characteristics in the web browser interface (Listing 1).
// 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 shown in Table 1. (Listing source: GitHub, STMicroelectronics)
Tracking BLE Stack Processes
The NUCLEO-WBA52CG integrates the ST-LINK/V3 online debugger and programmer, supporting STM32 virtual COM port drivers, allowing serial communication with a PC. 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 needs to be enabled in the app_conf.h file
#define CFG_DEBUG_APP_TRACE (1)
Additionally, the smartphone application “SE BLE Toolbox” provides tracking functionality on the tab.
BLE 5.3 Application Programming
To program the STM32WBA52 MCU, ST has launched the STM32CubeWBA software package, consisting of 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 for all three development environments (IDE): IAR Embedded Workbench for Arm (EWARM), Keil MDK-ARM, and STM32CubeIDE.

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

Efficient! Using This Wireless MCU to Design a BLE 5.3 Health Thermometer Sensor!
Figure 4: Programmers can add their GATT content in the framework code files (left) that generate GATT services (right). (Image source: STMicroelectronics)
Programmers can use the source code for their projects and extend it within the areas marked USER CODE BEGIN/USER CODE END, adding their GATT content (Listing 2). The initialization sequence in the file hts.c generates the GATT characteristic temperature measurement (TEMM), with a UUID of 0x2A1C.
复制[…] 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! Using This Wireless MCU to Design a BLE 5.3 Health Thermometer Sensor!
Figure 5: To achieve Bluetooth functionality, the RF terminal of the STM32WBA52 is connected to the impedance matching network, harmonic filter, and antenna. (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 highly challenging. The STM32WBA52 MCU integrates a BLE 5.3 interface, enabling developers to economically and efficiently bring products to market quickly. The pre-programmed BLE stack and multiple BLE application instances provide programming templates for custom 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 during design and implementation, such as power optimization, connection management, security, handling multiplexing, and broadcasting. To address these challenges, system designers need to consider the design of hardware, software, and protocol stacks comprehensively to optimize the overall system performance and stability. The MCU series mentioned in this article offers an excellent choice to address these pain points. What challenges have you encountered in BLE 5.3 system design? What considerations do you have when choosing a wireless MCU?Feel free to leave a comment and share your thoughts!
Efficient! Using This Wireless MCU to Design a BLE 5.3 Health Thermometer Sensor! The monthly answer prize code for this issue:Wireless MCU

Efficient! Using This Wireless MCU to Design a BLE 5.3 Health Thermometer Sensor!

Efficient! Using This Wireless MCU to Design a BLE 5.3 Health Thermometer Sensor!
Efficient! Using This Wireless MCU to Design a BLE 5.3 Health Thermometer Sensor!
Efficient! Using This Wireless MCU to Design a BLE 5.3 Health Thermometer Sensor!

Click below “Read the original” for more details

Let me know youare watching!
Efficient! Using This Wireless MCU to Design a BLE 5.3 Health Thermometer Sensor!

Leave a Comment