STM32 is a family of 32-bit microcontroller integrated circuits by STMicroelectronics. Based on ARM® Cortex®-M, STM32 is suitable for low power, real time applications.
The B-L475E-IOT01A (STM32L4 Discovery kit IoT node) allows users to develop applications with direct connection to cloud servers. The Discovery kit enables a wide diversity of applications by exploiting low-power communication like BLE. The support for Arduino Uno V3 and PMOD connectivity provides unlimited expansion capabilities with a large choice of specialized add-on boards.
This Repository contains the source code and the steps to follow to be able to make STM32 read sensor data and send it, in an organized way, to the Tangle (DLT) of the IOTA Network through the Streams layer.
We used the bsp library to read built-in sensors such as
- Accelerometer and gyroscope (LSM6DSL)
- Magnetometer (LIS3MDL)
- Altimeter / pressure sensor (LPS22HH)
- Humidity and temperature sensor (HTS221)
The source code can be built and flashed using the official IDE of St-microelectronics, supported IDEs are:
- STM32CubeIDE available for Linux, Mac and Windows
- SW4STM32 available for Linux, Mac and Windows
Clone the repository
git clone https://github.com/Mattia-Sacchi/BLE-Connectivity-Stm32.git
Once the installation of the IDE is complete click on .cproject file if you installed SW4STM32, the IDE will launch importing the project.
If you installed STM32CubeIDE click on the .project file and the IDE will import the project.
The name of the device can be edited in the file ble_project_interface.c the address instead will be fixed.
Connect the board to your pc using the (USB ST-link) connector, click on run on the IDE and the project will be compiled and flashed on the board. Press the reset button on the board and the device will start to work. The green led (LD2) will fade according to the distance measured with the ToF sensor. The green power led instead will be always on.
You may also want to read the data directly from the BLE Server. For this there are Free OpenSource software.
We recommend nRF Connect (free OpenSource software) of NordicSemiconductor available in Desktop: on Windows, macOS and Linux. And in Mobile: on Android and iOS (The mobile version is very simple and more comfortable to debug).
You may look the ble_project_interface.h/c files, in particular the Services and Messages enums. In the interface setup you can automatically setup service and charateristic through adding the enum and then call the respective setup function. In the setup the IDs will be automatically assigned
You may want read the charateristic with your phone/android-device, we developed a android basic app in order to do that: https://github.com/Gil-Dannen/Progetto/tree/main-android You can build it with android studio, just clone the repository in the branch "main-android" and you're ready to go.