Step5 Build an IOT system

Build an IOT systemClock.png30min

Target description
This tutorial shows how to program and use the Bluetooth interface to perform data communication between the STM32L4 Discovery kit IoT node (B-L475E-IOT01A) and an Android application running on a mobile device.
After this tutorial, you will be able to build an IoT system, control it from your mobile monitoring sensors and collect data.

Prerequisites
You have gone through:

Hardware

  • STM32L4 Discovery kit IoT node[1] (B-L475E-IOT01A )
  • USB cable Type-A to Mini-B

Literature


The purpose of this section is to explain step-by-step how to reuse one of the applications that are part of the STM32CubeL4 MCU package to create a communication channel between the IoT board emulating a heart rate monitor and a mobile device on which the data is displayed via an Android application.

1. Import and convert the HeartRate project from the STM32Cube package

  • In STM32CubeIDE, import the HeartRate example located in: C:\Users\user_name\STM32Cube\Repository\STM32Cube_FW_L4_Vx.xx.x\Projects\B-L475E-IOT01A\Applications\BLE\HeartRate
  • The project must be converted and the following message is displayed:

Project Converter 3.png

  • Click on OK and a new message confirms the success of the conversion

Project Converter OK 2.png

  • Click on OK and the STM32CubeIDE workspace opens

Project Panel.png

2. Build and execute the HeartRate Project

  • Select the STM32L4_IOT_HR project
  • Click on the Build button Built Button.png to rebuild the project.
  • Click on the Debug button Debug Button.png arrow and select Debug Configurations… and make sure the Debug probe parameter is set to ST-LINK. Otherwise the code is not properly downloaded on the board.

Debug Panel.png

  • Click on the Debug button Debug Button.png to run the software.
  • STM32CubeIDE opens the Debug perspective. Click on the Resume button Resume Button.png to execute the code.

3. Install the Android application on a mobile device

To interact with the IoT board, an Android application has to be installed on a mobile device.
The STM32 BLE Profile application is a companion tool to show in a human readable form all notifications coming from Bluetooth Low Energy (BLE) devices implementing some peripheral profiles.
BLE Profile App.png

4. Connect to the IoT node

  • Go to Google Play store and install the “STM32 BLE Profiles” application on your mobile device.
  • Once installed, simply launch the STM32 BLE Profiles application. The application scans the network and displays a list of discovered BLE devices (Here the HeartRateSensor device).

BLE Scan.png

  • Establish a Bluetooth connection with the B-L475E-IOT1A board selecting the HR_L475_IoT device from the discovered devices list. It can take a while to get the connection established.
  • The following screenshot shows the successful pairing with a health thermometer sensor:

BLE HR.png

  • Once connected, select the Heart Rate profile among the BLE profiles proposed.

The application starts to display the heart rate data sent by the IoT connected device, which acts as a peripheral. In this example, the data is generated on the B-L475E-IOT1A board via a formula and does not reflect the data from a real sensor.
BLE Result.png
Now you are able to:

  • Build your own IoT system to get values from a peripheral device and display them on your mobile device
  • Regenerate a project from one of the various applications available in the STM32Cube package.

5. References



Previous step Arrow left.png