ST STM32Cube User manual

Introduction
FP-SNS-SMARTAG2 is an STM32Cube function pack that allows you to read the ambient light, the motion, and the
environmental sensor data on the STEVAL-SMARTAG2 evaluation board. These functions are performed via an NFC-enabled
reader, such as a mobile phone or a tablet. The package supports battery-operated use cases.
This software, together with the suggested combination of STM32 and ST devices, can be used to develop tracking, cold chain,
medical, smart sensing, smart home, city, and building applications.
The package contains also a simple example that shows how to make the firmware update using the NFC and ST25 NFC tap
application for Android/iOS.
The software runs on an STM32L4 ultralow power microcontroller. It includes drivers for the dynamic NFC tag and for the
ambient light, motion, and environmental sensors.
You can register the NFC sensor tag node on the DSH-ASSETRACKING web application for asset tracking, which stores and
monitors on-board sensor data, as well as the geo-localization of the smartphone used to read the IoT node data.
Related links
Visit the STM32Cube ecosystem web page on www.st.com for further information
Getting started with the STM32Cube function pack for STEVAL-SMARTAG2
evaluation board with dynamic NFC tag, environmental, motion, and ambient light
sensors
UM3073
User manual
UM3073 - Rev 1 - October 2022
For further information contact your local STMicroelectronics sales office.
www.st.com

1FP-SNS-SMARTAG2 software description
1.1 Overview
The key features of the FP-SNS-SMARTAG2 package are:
• Complete firmware to access data from an IoT node with a dynamic NFC tag, environmental, motion, and
ambient light sensors
– Compatible with the STAssetTracking application for Android/iOS. This allows data logs reading from
the NFC tag and data logs sending to the DSH-ASSETRACKING cloud-based dashboard
– Compatible with the STNFCSensor application for Android/iOS for reading and setting the data logs
• The package contains also one example that shows how to update the firmware using the fast transfer mode
protocol (ST25FTM)
– Compatible with the ST25 NFC tag application to download the firmware on the board via NFC
• Sample implementation available for the STEVAL-SMARTAG2 evaluation board
• Easy portability across different MCU families, thanks to STM32Cube
The package contains software to:
1. track the temperature, pressure, luminosity, and vibration values in a fixed time range, sending them via
NFC. Using an Android or iOS device, you can monitor and display the logged data
The software gathers:
– the temperature, pressure, luminosity, and vibration sensor data for the STS22H, LPS22DF, VD6283,
LSM6DSO32X, and ST25DV64K devices for the STEVAL-SMARTAG2 evaluation board running the
STM32
This package is compatible with the STAssetTracking Android (version 3.1.0 or higher)/iOS (version 3.1.0 or
higher) application and with the STNFCSensor Android/iOS application (version 1.3.0 or higher) available on
GooglePlay/App stores, to read the information sent via the NFC/RFID tag IC protocol
2. update the firmware, using the ST25 NFC tag application (version 3.7.0 or higher) available on
GooglePlay/App stores
1.2 Architecture
The STM32Cube function packs leverage the modularity and interoperability of the STM32 Nucleo and the
expansion boards, as well as of the STM32Cube and the expansion software, in order to create function
examples, embodying some of the most common use cases for each application area.
These software function packs are designed to exploit as much as possible the underlying STM32 ODE hardware
and software components to fit best the requirements of final users’ applications.
Moreover, function packs may include additional libraries and frameworks, which do not present the original
expansion software packages, thus enabling new functionalities and creating a real and usable system for
developers.
To access and use the sensor expansion board, the application software uses:
•STM32Cube HAL layer: provides a simple, generic, and multiinstance set of generic and extension APIs to
interact with the upper layer application, libraries, and stacks. It is directly based on a generic architecture
and allows the layers that are built on it, such as the middleware layer, to implement their functions without
requiring the specific hardware configuration for a given microcontroller unit (MCU). This structure improves
the library code reusability and guarantees an easy portability across other devices.
•Board support package (BSP) layer: supports the peripherals on the STM32 Nucleo development board
(except the MCU) with a limited set of APIs, providing a programming interface for certain board-specific
peripherals like the LED, the user button, etc. It helps determine the specific board version. For the sensor
expansion board, it provides the programming interface for various inertial and environmental sensors and
supports the sensor data initialization and reading.
UM3073
FP-SNS-SMARTAG2 software description
UM3073 - Rev 1 page 2/42

Figure 1. FP-SNS-SMARTAG2 software architecture
Applications &
Examples SmarTag2
STM32Cube Hardware Abstraction
Layer API
Middleware
Hardware
Abstraction
Hardware STEVAL-SMARTAG2 EVALUATION-BOARD
FirmwareUpdate BootLoader
ST25FTM
1.3 Folder structure
Figure 2. FP-SNS-SMARTAG2 folders
The following folders are included in the software package:
•Documentation: contains a compiled HTML file generated from the source code, detailing the software
components and APIs.
•Drivers: contains the HAL drivers, the board specific drivers for each supported board or hardware platform,
including the on-board components, and the CMSIS vendor-independent hardware abstraction layer for the
Cortex-M processor series.
•Middlewares: contains libraries and protocols for the ST25 fast transfer mode (ST25FTM).
•Projects: contains
–three different projects for the STEVAL-SMARTAG2, which are compatible with the IAR Embedded
Workbench for ARM, Real View Microcontroller Development Kit (MDK-ARM) and the integrated
development environment for STM32 (STM32CubeIDE)
1. a sample application (SmarTag2) used to read the motion, luminosity, and environmental sensor
data on your IoT node via an NFC-enabled reader, such as a mobile phone or a tablet
2. a sample application (FirmwareUpdate) used to update the firmware via NFC using the ST fast
transfer protocol
3. a bootloader example (SimpleBootLoader) that must be used with the firmware update application
to enable the capability of updating the current firmware running on the STEVAL-SMARTAG2
UM3073
Folder structure
UM3073 - Rev 1 page 3/42

1.4 APIs
Detailed user-API technical information with full function and parameter descriptions is available in a compiled
HTML file in the package “Documentation” folder.
1.5 Sample application description
The sample applications available for the STEVAL-SMARTAG2 evaluation board are:
• SmarTag2
• SimpleBootLoader
• FirmwareUpdate
Ready-to-build projects are available for multiple IDEs.
1.5.1 SmarTag2 application description
You can set up a terminal window for the appropriate UART communication port in order to control the
initialization phase, as shown in the figure below.
Figure 3. FP-SNS-SMARTAG2 terminal setting
Note: To enable/disable this UART functionality on the STEVAL-SMARTAG2 board, you must recompile the code by
uncommenting/commenting the line:
#define SMARTAG2_ENABLE_PRINTF
in the Projects\ STM32L4P5CE-SmarTag2\Examples\SmarTag2\Inc\SMARTAG2_config.h file.
UM3073
APIs
UM3073 - Rev 1 page 4/42

When you first press the reset button, the application:
•starts initializing the UART and I²C interfaces
• shows the SmarTag UID
• reads the last configuration written on to NFC tag (if available)
• sets the NFC behavior
• sets the wakeup timer
Figure 4. FP-SNS-SMARTAG2 UART output initialization
After the auto-start range time, the samples are logged using the written configuration on the NFC tag (or the
default one, if not available).
UM3073
Sample application description
UM3073 - Rev 1 page 5/42

Figure 5. FP-SNS-SMARTAG2 UART output auto-start
When the smartphone is close to the NFC tag, the message "Detected NFC FIELD On" appears.
UM3073
Sample application description
UM3073 - Rev 1 page 6/42

Figure 6. FP-SNS-SMARTAG2 UART output NFC on
When the smartphone is kept distant from the NFC tag, the message "Detected NFC FIELD Off" appears together
with the new configuration if a new one is detected.
UM3073
Sample application description
UM3073 - Rev 1 page 7/42

Figure 7. FP-SNS-SMARTAG2 UART output NFC off
1.5.1.1 SmarTag2: Android and iOS sample client application
The SmarTag2 application is compatible with the STAssetTracking Android (version 3.1.0 or higher)/iOS (version
3.1.0 or higher) application and with the STNFCSensor Android/iOS application (version 1.4.0 or higher) available
at their respective GooglePlay/App store.
The next sections show some use cases enabled by the Android application.
UM3073
Sample application description
UM3073 - Rev 1 page 8/42

1.5.1.1.1 Sign-in with MyST
If you are not signed-in or you are not registered on MyST, when you open the STAssetTracking application, the
following page appears.
Figure 8. Sign-in with MyST (1 of 2)
Click on "Sign-in with MyST". Then, insert your e-mail address and password to execute the login if you are
already registered. Otherwise, click "New User" and follow the instructions.
UM3073
Sample application description
UM3073 - Rev 1 page 9/42

Figure 10. STAssetTracking after signing-in to MyST
Click on the "+" button to register a new device and scroll down to find the Smartag2 device.
UM3073
Sample application description
UM3073 - Rev 1 page 11/42

Figure 11. STAssetTracking - registering a new device (1 of 3)
Click on the add button and put the mobile phone on top the device to detect the tag by NFC. When the tag is
detected, the device ID is shown:
UM3073
Sample application description
UM3073 - Rev 1 page 12/42

Figure 12. STAssetTracking - registering a new device (2 of 3)
Insert the device name and click on the add button to complete the process.
UM3073
Sample application description
UM3073 - Rev 1 page 13/42

Figure 15. STAssetTracking - device info
Select settings and put the mobile phone on top the device to detect the tag by NFC. When the tag is detected,
the application shows the following page.
UM3073
Sample application description
UM3073 - Rev 1 page 16/42

Figure 16. STAssetTracking - settings
From this page, you can select the data to be logged (temperature, pressure, luminosity, IMU accelerometer,
6-axis orientation, and tilt) with the related data range as well as the time interval.
1.5.1.1.4 Extremes
This page shows the maximum and minimum values obtained during the logging of the selected data.
UM3073
Sample application description
UM3073 - Rev 1 page 17/42

Figure 17. STAssetTracking - Extremes
1.5.1.1.5 Samples
This page collects all the data logging for the selected data with the related data range.
UM3073
Sample application description
UM3073 - Rev 1 page 18/42

Figure 18. STAssetTracking - samples
1.5.2 FirmwareUpdate and SimpleBootLoader applications description
The FirmwareUpdate application must work with the SimpleBootLoader example to enable the firmware update
capability.
The FirmwareUpdate receives the new firmware via NFC using the ST FTM protocol and saves it on the right
flash memory region.
The SimpleBootLoader replaces the FirmwareUpdate firmware currently running with the new version received
via NFC.
1.5.2.1 Firmware update
You can set up a terminal window for the appropriate UART communication port in order to control the
initialization phase, as shown in the figure below.
UM3073
Sample application description
UM3073 - Rev 1 page 19/42

Figure 19. FP-SNS-SMARTAG2 terminal setting
Note: To enable/disable this UART functionality on the STEVAL-SMARTAG2 board, you must recompile the code by
uncommenting/commenting the line: #define SMARTAG2_ENABLE_PRINTF in the Projects\ STM32L4P5CE-
SmarTag2\Applications\ FirmwareUpdate\Inc\Firmware_conf.h file.
When you first press the reset button, the application:
• initializes the UART
• initializes the NFC tag
• changes the I²C password on the NFC tag
• writes the interrupt configuration
UM3073
Sample application description
UM3073 - Rev 1 page 20/42
Other manuals for STM32Cube
6
This manual suits for next models
1
Table of contents
Other ST Computer Hardware manuals

ST
ST X-NUCLEO-IDB04A1 User manual

ST
ST Nomadik NHK-15 User manual

ST
ST STM32 Nucleo User manual

ST
ST X-NUCLEO-S2915A1 User manual

ST
ST STM32F3 Series Owner's manual

ST
ST STEVAL-ST25R3916B User manual

ST
ST X-NUCLEO-53L5A1 User manual

ST
ST STEVAL-IFP046V1 User manual

ST
ST STM32W-RFCKIT User manual

ST
ST FP-LIT-BLEMESH1 User manual