ST Microelectronics STILE01 User Manual

May 2016
DocID029208 Rev 2
1/37
www.st.com
User manual
Getting started with the software package for Bluetooth low
energy and sensors in BLUEMICROSYSTEM2
STEVAL-STLKT01V1
Introduction
The BLUEMICROSYSTEM2 expansion software package for STM32Cube lets you read and display real-time environmental sensor data, digital microphone levels and acoustic source localization information with a dedicated Android™/iOS™ application.
The package implements application level functions based on the Bluetooth low energy protocol and enables communication with Android/iOS devices. Developers can use it to prototype applications with Android/iOS services, and transmit real-time sensor data with ease.
The software runs on the STM32 microcontroller and includes drivers that recognize the Bluetooth low energy (BlueNRG) hardware, the four sensor devices and 2 MEMS microphones. The expansion is built on the STM32Cube framework for STM32 microcontrollers and comes with a sample implementation to kick-start development.
Contents
2/37
DocID029208 Rev 2
STEVAL-STLKT01V1
Contents
1 BLUEMICROSYSTEM2 software description ................................ 5
1.1 Overview ........................................................................................... 5
1.2 Architecture ....................................................................................... 6
1.3 Folder structure ................................................................................. 7
1.4 APIs .................................................................................................. 8
1.5 Sample application description .......................................................... 8
1.6 Android and iOS sample client application ...................................... 11
2 System setup guide ....................................................................... 26
2.1 Hardware description ...................................................................... 26
2.1.1 STM32 Nucleo platform .................................................................... 26
2.1.2 X-NUCLEO-CCA02M1 expansion board ......................................... 26
2.1.3 X-NUCLEO-IDB04A1 expansion board............................................ 27
2.1.4 X-NUCLEO-IDB05A1 expansion board............................................ 28
2.1.5 X-NUCLEO-IKS01A1 expansion board ............................................ 29
2.2 Software description ........................................................................ 30
2.3 Hardware and software setup ......................................................... 31
2.3.1 Hardware setup ................................................................................ 31
2.3.2 Software setup .................................................................................. 31
2.3.3 System setup guide .......................................................................... 31
3 Revision history ............................................................................ 36
STDK-STILECS01V1
List of tables
DocID029208 Rev 2
3/37
List of tables
Table 1: Document revision history .......................................................................................................... 36
List of figures
4/37
DocID029208 Rev 2
STEVAL-STLKT01V1
List of figures
Figure 1: BLUEMICROSYSTEM2 software architecture ............................................................................ 7
Figure 2: BLUEMICROSYSTEM2 package folder structure ....................................................................... 7
Figure 3: Terminal setting ........................................................................................................................... 8
Figure 4: Initialization phase ....................................................................................................................... 9
Figure 5: UART console output when one device is connected to the board........................................... 11
Figure 6: BlueMS (Android version) initial page after BLE connection ..................................................... 12
Figure 7: BlueMS (Android version) osxMotionFX sensor fusion page .................................................... 13
Figure 8: BlueMS (Android version) popup windows ................................................................................ 14
Figure 9: BlueMS (Android version) mic level plot .................................................................................... 15
Figure 10: BlueMS (Android version) accelerometer plot ......................................................................... 16
Figure 11: BlueMS (Android version) menu selection .............................................................................. 17
Figure 12: BlueMS (Android version) Serial console (stdout/stderr) ........................................................ 18
Figure 13: BlueMS (Android version) Debug console (stdin/stdout/stderr) .............................................. 19
Figure 14: BlueMS (Android version) LSM6DS3 DIL24 hardware features ............................................. 20
Figure 15: BlueMS (Android version) LSM6DS3 DIL24 examples: pedometer, wake up, orientation,
double tap. ................................................................................................................................................ 21
Figure 16: BlueMS (Android version) osxMotionAR activity recognition page ......................................... 22
Figure 17: BlueMS (Android version) osxMotionCP carry position recognition page ............................... 23
Figure 18: BlueMS (Android version) osxMotionGR gesture recognition page ........................................ 24
Figure 19: BlueMS (Android version) example of audio source localization plot value ............................ 25
Figure 20: STM32 Nucleo board ............................................................................................................... 26
Figure 21: X-NUCLEO-CCA02M1 board .................................................................................................. 27
Figure 22: X-NUCLEO-IDB04A1 expansion board ................................................................................... 28
Figure 23: X-NUCLEO-IDB05A1 expansion board ................................................................................... 29
Figure 24: X-NUCLEO-IKS01A1 board .................................................................................................... 30
Figure 25: LSM6DS3 DIL24 adapter board .............................................................................................. 30
Figure 26: STM32 Nucleo plus X-NUCLEO-CCA02M1 boards ............................................................... 32
Figure 27: STM32 Nucleo plus X-NUCLEO-CCA02M1 plus X-NUCLEO-IDB04A1 boards .................... 32
Figure 28: STM32 Nucleo plus X-NUCLEO-CCA02M1 plus X-NUCLEO-IDB04A1 plus X-NUCLEO-
IKS01A1 plus LSM6DS3 DIL24 boards .................................................................................................... 33
Figure 29: Resistors to remove from X-NUCLEO-IKS01A1 board ........................................................... 34
Figure 30: Solder bridges to close on X-NUCLEO-CCA02M1 board (when using NUCLEO-L476RG
board) ........................................................................................................................................................ 35
STEVAL-STLKT01V1
BLUEMICROSYSTEM2 software description
DocID029208 Rev 2
5/37
1 BLUEMICROSYSTEM2 software description
1.1 Overview
The key features of the BLUEMICROSYSTEM2 package are: Complete middleware to build applications using temperature and humidity sensors
(HTS221), pressure sensor (LPS25HB), motion sensors (LIS3MDL and LSM6DS0) and microphone sensor (2x MP34DT01-M)
Compatible with the motion sensor LSM6DS3 DIL24 expansion component  Very low power Bluetooth low energy (BlueNRG) single-mode network processor for
transmitting information to one client.
osxMotionFX (iNEMOEngine PRO) real-time motion sensor data fusion (under
OPEN.MEMS license) to combine the output from multiple MEMS sensors.
Accelerometer-only algorithms:
osxMotionAR (iNEMOEngine PRO) real- time activity-recognition algorithm
(under OPEN.MEMS license)
osxMotionCP (iNEMOEngine PRO) real-time carry-position recognition algorithm
(under OPEN.MEMS license)
osxMotionGR (iNEMOEngine PRO) real- time gesture recognition algorithm
(under OPEN.MEMS license)
osxAcousticSL Real-time sound source localization software expansion (under
OpenSoftwareX license) based on two or four digital microphone audio signals.
Based on common STM32Cube framework  BlueMS compatible application for Android/iOS (version 2.0.0 or above) for visualizing
information sent via Bluetooth.
Free, user-friendly license terms  Sample implementation available on X-NUCLEO-CCA02M1, X-NUCLEO-IKS01A1
and X-NUCLEO-IDB04A1 or X-NUCLEO-IDB05A1 boards when connected to a NUCLEO-F401RE or NUCLEO-L476RG board.
This software creates the following Bluetooth services:
1. The first service exposes all the hardware features with the following characteristics:
Temperature  Pressure  Humidity  3D gyroscope, 3D magnetometer, 3D accelerometer  Microphones dB noise level.
2. The second service exposes the software characteristics:
the quaternions generated by the osXMotionFX library in short precision  the activity recognized using the osxMotionAR algorithm  the carry position recognized using the osxMotionCP algorithm  the gesture recognized using the osxMotionGR algorithm  the audio source localization (for only F4 STM32 Nucleo motherboard) using the
osxAcousticSL algorithm
3. The third service exposes the Console service with:
stdin/stdout for bi-directional communication between client and server  stderr for a mono-directional channel from the STM32 Nucleo board to an
Android/iOS device
4. The last service is for transmitting/resetting the calibration status and enabling the following LSM6DS3 DIL24 expansion hardware features when it is mounted: Pedometer
BLUEMICROSYSTEM2 software description
6/37
DocID029208 Rev 2
Free Fall detection  Single tap detection  Double tap detection  Wake up detection  Tilt detection  3D orientation
This software gathers the temperature, humidity, pressure, audio and motion sensors drivers for the HTS221, LPS25H, MP34DT01-M, LSM6DS0 (or LSM6DS3) and LIS3MDL
devices, running on STM32. This package is compatible with the BlueMS Android/iOS (Version 2.0.0 or higher)
application available at respective Play/iTunes stores, which can be used for displaying information sent via the Bluetooth low energy protocol. To use the hardware features of the LSM6DS3 DIL24 device, use BlueMS Android/iOS application version 2.2.0 or higher.
1.2 Architecture
The software is based on the STM32CubeHAL hardware abstraction layer for the STM32 microcontroller.
The package provides a Board Support Package (BSP) for the sensors expansion board and middleware components for serial communication with a PC.
To access and use the sensor expansion board, the application software uses:
STEVAL-STLKT01V1
STM32Cube HAL layer: provides a simple, generic and multi-instance set of generic
and extension APIs (application programming interfaces) 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 library code reusability and guarantees easy portability across other devices.
Board support package (BSP) layer: supports the peripherals on the STM32 Nucleo
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., and helps determine the specific board version. For the sensor expansion board, it provides the programming interface for various inertial and environmental sensors and support for initializing and reading sensor data.
STEVAL-STLKT01V1
BLUEMICROSYSTEM2 software description
DocID029208 Rev 2
7/37
Figure 1: BLUEMICROSYSTEM2 software architecture
1.3 Folder structure
This section provides an overview of the package folders structure. The next figure outlines the architecture of the package
Figure 2: BLUEMICROSYSTEM2 package folder structure
The following folders are included in the software package: Documentation: contains a compiled HTML file generated from the source code,
which details 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.
BLUEMICROSYSTEM2 software description
8/37
DocID029208 Rev 2
Middlewares: contains libraries and protocols for BlueNRG Bluetooth low energy,
osx.MotionFX (iNEMOEngine PRO) sensors fusion library, osx.MotionAR (iNEMOEngine PRO) activity-recognition library, osx.MotionCP (iNEMOEngine PRO) carry-position recognition library, osx.MotionGR (iNEMOEngine PRO) gesture recognition library and osx.AcousticSL sound source localization library.
Projects: contains a sample application used for transmitting the output of the sensor
data and of the osx.MotionFX sensor fusion, osx.MotionAR activity-recognition, osx.MotionCP carry-position, osx.MotionGR gesture recognition and osx.AcousticSL sound source localization libraries by using the Bluetooth low energy protocol provided for the NUCLEO-F401RE/NUCLEO-L476RG platforms through the IAR Embedded Workbench for ARM, RealView Microcontroller Development Kit (MDK-ARM) and System Workbench for STM32 development environments.
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
A sample application using the X-NUCLEO-IKS01A1, X-NUCLEO-CCA02M1 and X­NUCLEO-IDB04A1 or X-NUCLEO-IDB05A1 expansion boards with the NUCLEO-F401RE or NUCLEO-L476RG board is provided in the “Projects” directory. Ready to build projects are available for multiple IDEs.
STEVAL-STLKT01V1
Application behavior can be controlled via UART with a terminal application and the following settings for the appropriate port.
Figure 3: Terminal setting
When you first press the reset button, the application:
starts initializing the UART, I²C and SPI interfaces  creates a random BLE MAC address and a random connection PIN necessary for
making the connection
initializes the BLE hardware service adding the temperature, humidity, pressure, 3D
gyroscope, 3D magnetometer, 3D accelerometer and microphone characteristics
STDK-STILECS01V1
BLUEMICROSYSTEM2 software description
DocID029208 Rev 2
9/37
initializes the BLE SW service adding the osx.MotionFX, osx.MotionAR,
osx.MotionCP, osx.MotionGR and osx.AcousticSL libraries.
initializes the BLE console service adding the stdin/stdout and stderr characteristics  initializes the BLE config service transmitting/resetting the calibration status and
enabling the LSM6DS3 DIL24 hardware features (if present).
checks whether the LSM6DS3 DIL24 extension is present.  Checks whether all the sensors are present and working.  controls whether the osxMotionFX, osxMotionAR, osxMotionCP, osxMotionGR and
osxAcousticSL libraries have been initialized properly with valid licenses.
determines which BlueNRG expansion board is connected to the STM32 Nucleo
board (X-NUCLEO-IDB04A1 or X-NUCLEO-IDB05A1) and hardware and firmware version information.
If the LSM6DS3 DIL24 extension is present, the system is able also to understand a free fall situation because the DS3 generates one interrupts when there is free fall situation. This situations is transmitted over Bluetooth to the attached Android™/iOS™ device.
Figure 4: Initialization phase
As shown in the console output above, the application sends:
3 short precision quaternions every 30ms  Temperature/Humidity/Pressure data every 500ms  3D Accelerometer, 3D Gyroscope and 3D Magnetometer data every 50ms  signal noise microphone levels every 50ms
This application reads the accelerometer, magnetometer and gyroscope values at 100 samples/second. The osxMotionFX (iNEMOEngine PRO) library combines these sensor values to produce and transmit 100 quaternions/second to the client connected via Bluetooth low energy to reflect real motion using a vendor-specific BLE service.
BLUEMICROSYSTEM2 software description
10/37
DocID029208 Rev 2
STEVAL-STLKT01V1
These definitions in osx_bms_config.h control how many quaternions the application sends to the Bluetooth client:
QUAT_UPDATE_MUL_10MS: defines the transmission rate for each set of quaternions
by multiple of 10 ms.
SEND_N_QUATERNIONS: defines how many quaternions are sent on each Bluetooth
package.
By default, the application sends 3 quaternions every 30 ms. The same osx_bms_config.h file also defines: ENV_UPDATE_MUL_10MS the transmission rate for Temperature/Pressure and
Humidity/Lux
ACC_GYRO_MAG_UPDATE_MUL_10MS the transmission rate for Acc/Gyro and
Magneto values
OSX_BMS_DEBUG_CONNECTION and OSX_BMS_DEBUG_NOTIFY_TRAMISSION to
enable some debugging information for BLE communication
OSX_BMS_MOTIONAR to enable the osxMotionAR activity recognition algorithm  OSX_BMS_MOTIONCP to enable the osxMotionCP carry position recognition algorithm  OSX_BMS_MOTIONGR to enable the osxMotionGR gesture recognition algorithm  OSX_BMS_ACOUSTIC_MIC_ANGLE to enable the osxAcousticSL audio source
localization algorithm (only NUCLEO-F401R Nucleo board)
The osxMotionFX (INEMOEngine PRO) library has an autocalibrating procedure and the calibration status is transmitted via BLE to the client. By pressing the user button on the NUCLEO-F401RE (or NUCLEO-L476RG) board, it is possible to reset the library calibration status, thereby forcing a new autocalibration procedure.
The osxMotionAR (INEMOEngine PRO) library is able to recognize the following activities:
Stationary  Walking  fast walking  jogging  biking  driving
The osxMotionAR can be enabled via the OSX_BMS_MOTIONAR define in osx_bms_config.h.
The osxMotionCP (INEMOEngine PRO) library recognizes and provides real-time information about how the user is carrying the board, which equates to the phone carry position:
on desk  in hand  near head  shirt pocket  trouser pocket  arm swing
The osxMotionCP can be enabled via the OSX_BMS_MOTIONCP define in osx_bms_config.h.
The osxMotionGR (INEMOEngine PRO) library is able to recognize gestures like:
pick up  glance  wake up in hand
STEVAL-STLKT01V1
BLUEMICROSYSTEM2 software description
DocID029208 Rev 2
11/37
The osxMotionGR can be enabled via the OSX_BMS_MOTIONGR define in osx_bms_config.h.
The osxAcousticSL library is able to localize the audio sound source using the data acquired from the microphones. It can be enabled via the OSX_BMS_ACOUSTIC_MIC_ANGLE define in osx_bms_config.h.
When an Android/iOS device is connected to the board, it is possible to control what the board transmit (see the following figure).
Figure 5: UART console output when one device is connected to the board
1.6 Android and iOS sample client application
The BLUEMICROSYSTEM2 software for STM32Cube is compatible with the BlueMS Android/iOS applications (Version 2.0.0 or higher) available at the respective Play/iOS stores. The LSM6DS3 DIL24 hardware features are only visible with BlueMS Android/iOS version 2.2.0 or higher.
We will use Android application to demonstrate how it works.
BLUEMICROSYSTEM2 software description
12/37
DocID029208 Rev 2
STEVAL-STLKT01V1
Following connection, BlueMS starts with the main page shown below, where the values of temperature, pressure and humidity are displayed.
Figure 6: BlueMS (Android version) initial page after BLE connection
Loading...
+ 27 hidden pages