Skip to content

Connecting the STM32 Nucleo board to your smartphone

Introduction

The STM32 Nucleo board allows developers to try out new ideas and quickly create prototypes with the STM32 MCUs. STM32 Nucleo boards can easily be extended with wireless capabilities using a TapNLink module. In this tutorial we will be programming our Nucleo-L476RG with a project that use an ADC peripheral to perform a single ADC conversion of the internal temperature sensor, then connect it to a TapNLink Primer to send the temperature data by BLE to a mobile phone.

STM32 Nucleo Board

Prerequisites

  • TapNLink Primer Evaluation Kit: this is an evaluation kit that allows iot designers to test all the advantages of IoTize TapNLink products for building a connected electronic system. You can purchase a TapNLink Primer Evaluation Kit from Digikey.

  • IoTize Studio: the PC-based configuration software that we will use for configuring TapNLink Primer. You can download and install the software from http://docs.iotize.com/Downloads.

  • NUCLEO-L476RG board: Affordable and flexible platform to ease prototyping using a STM32L476RG microcontroller. You will find additional information about this platform from ST website.

  • STM32CubeL4 MCU Firmware Package: The STM32CubeL4 software platform for the STM32L4 series. You can find this package on GitHub. For this tutorial we will be using the ADC_TemperatureSensor from the sample projects.

  • STM32 Software Development tools: You will need an integrated development environment (IDE) with C compiler and debugger as well as the embedded software libraries required to configure and initialize the MCU with the project samples. In this tutorial we will be using Raisonance Tools that you can download and use for free ( up to 64 Kbytes of code ) but you can use any other STM32 development toolchain for building and programming the sample project.

  • 'Tap Manager' app on a mobile phone: TapNLink companion App, helping with Taps configuration in developer mode. Tap Manager could also be used as the 'End User' monitoring App with TapNLinks. Tap Manager is available on Google Play for Android smartphones and App Store for iPhones.

Part1: Program NUCLEO-L476RG board with ADC_TemperatureSensor application

The first step is to build ADC_TemperatureSensor sample application and program the Nucleo board microcontroller with this program.

If you already know how to do program your Nucleo board you can skip this step and go directly to Part2. Although you can use any preferred programming tool for this purpose, in this tutorial we are going to use Ride7 and TapNLink Primer. Please note that for using TapNLink Primer as a programmer you need a BLE enabled Windows 10 (version 1803 or above). If your PC does not have a BLE device integrated you can also ude Ride7 with ST-Link

Step1: Build ADC_TemperatureSensor application

This sample project describes how to use an ADC peripheral to perform a single ADC conversion of the internal temperature sensor and to calculate the temperature in degree Celsius.

Launch Ride7 IDE, select Keil µVision project Filter from File|Open Project command, browse directories and open the Keil µVision project located in :

{STM32CubeL4 Directory}\Projects\NUCLEO-L476RG\Examples_LL\ADC\ADC_TemperatureSensor\MDK-ARM\Project.uvprojx

Open Project

Ride7 will automatically convert the uvprojx to an rprj and import the corresponding settings. Use 'Project|Build Project' command to build the application.

Ride7

For the purpose of this tutorial, we are temporarily disconnecting the embedded ST-Link debugger and use the STM32 debug ports to connect TapNLink module: - Remove the SWDIO jumpers but leave the SWDCLK jumpers. Please make sure that your are using an USB charger to power the Nucleo board, as connecting the board to a PC will wake-up the ST-Link debugger and prevent TapNLink to access the SWD signals.

Disconnect ST-Link
  • Connect TapNLink to the pins on CN7:
    Connect TapNLink
    Connect TapNLink

The resulting connected hardware:

Connect Hardware

From the STM32_Sensor Local settings pane, select TapNLink as the application’s debugging tool. Then scroll down the settings pane to reach the RLink configuration| Advanced Options:

Settings

Click on 'Click here to open dialog box' button to configure TapNLink advanced options.

Settings

In the Advanced debugger selection dialog box, select TapNLink as the debugger tool, and BLE for the communication protocol. If you don’t know the advertised name of your TapNLink Primer device, you can click the button beside the Name or Address text field: Ride7 will scan and display the available devices, so you can find and select yours.

Settings

TapNLink connection to the target is protected with a User\Profile permission system. TapNLink Primers are coming with a default configuration, and Ride7 will use this default administrator login to get access to the target application.

Settings

Select Ok to close the dialog box. You are now ready to start programming NUCELO board microcontroller and start debugging the ADC_TemperatureSensor application. Select Debug|Start command from the command bar and press ok to close the Cortex Debug Options dialog box.

Ride7 will program the Nucleo board using a BLE connection with your PC. You can monitor and debug the programmed application using Ride7 debugger.

If you have skipped the previous section and have not yet connected TapNLink to your Nucleo board, please refer to the previous section to setup the connection. In this part we are going to configure TapNLink to read the temperature value calculated in ADC_TemperatureSensor application and send it to a smartphone.

Launch IoTize Studio and create a new .iotz project located in ADC_TemperatureSensor directoy:

{STM32CubeL4 Directory}\Projects\NUCLEO-L476RG\Examples_LL\ADC\ADC_TemperatureSensor\MDK-ARM\STM32L476RG_NUCLEO\Project.elf

Use the Firmware field in the New Project dialog box to browse for the generated application so that IoTize Studio could load the debug symbols directly from the elf file.

Settings

Step2: Select variables to be read from ADC_TemperatureSensor application

IoTize Studio will generate a default configuration file with a single Main Bundle and load the Project.elf application debug symbols as displayed in the Resource View.

IoTize Studio

We are going to configure TapNLink to handle two variables: - ubUserButtonPressed that enables reading and converting the internal temperature sensor value of the microcontroller. - hADCxConvertedData_Temperature_DegreeCelsius that represents the measured temperature in degree Celsius.

To do so, you can select the variable name from the Resource View, drag and drop the variable to the Main Bundle in the IOTZ Explorer.

Then select each variable to setup the way the variable is handled by TapNLink:

  • ubUserButtonPressed: Rename the variable to 'Enable'(Alias) ,and select Propose Submit to yes in order to be able to modify this value from the generated UI.
IoTize Studio
  • hADCxConvertedData_Temperature_DegreeCelsius: Rename the variable to 'Temperature'(Alias) ,and set the Unit to '°C'.
IoTize Studio

IoTize Studio will automatically generate and display an HTML based UI for our mobile App.

IoTize Studio



In order to keep this guide simple, we will not detail the other TapNLink configuration settings. Refer to the User Manuals to learn more about TapNLink technologies and configuration.

To configure TapNLink with our settings, we will use IoTize Studio and a BLE connection between the PC and TapNLink. If your PC is not BLE enabled, there are other choices, refer to IoTize Studio Manual to learn more.

  • Select Studio and in the Setting pane select the BLE protocol and click on '...' button to display the list of BLE TapNLinks in order to select your TapNLink Primer as following:

    IoTize Studio

  • Select TEST|Test connection command to verify the connection between Studio and TapNLink. Upon a successfull connection to TapNLink, Studio will read the Serial Number of your TapNLink and display the following messagebox:

    IoTize Studio

Click Ok to modify the settings according to your specific TapNLink.

  • Select CONFIGURATION|Write to Tap command to transfer the configuration to TapNLink.

  • Select TEST|Monitor command to verify the configuration of TapNLink. Modify the enable button value to set the the value to 1. This will enable reading the sensor value and display the value of the measured temperation on our display.

    IoTize Studio

Part3: Monitor the Nucleo board from a smartphone

Once TapNLink is configured to handle ADC_TemperatureSensor variables and send them by BLE, we are ready to use the auto-generated web pages to monitor the application from a smartphone.

Step1: Upload the generated HTML pages to 'IoTize Primer Cloud Services'

We will upload the auto-generated web pages to 'IoTize Primer Cloud Services' and use Tap Manager app to connect to TapNLink by BLE from a mobile phone. IoTize provides a free website hosting service 'IoTize Primer Cloud Services' that comes with your TapNLink Primer and is handy for your testing and prototyping with TapNLink.

To upload the generated pages to 'IoTize Primer Cloud Services' select PROJECT|Publish command.

If your Android or iOS smartphone is NFC enabled you can launch Tap Manager and connect to your TapNLink with a single NFC tap. Otherwise, launch Tap Manager and select the TapNLink device from the list of available BLE devices.

IoTize Studio

Tap Manager will automatically display the web pages from the Cloud and start the communication session with the Nucleo board.

IoTize Studio

To go further