Send Sigfox messages with STM32 + S2LP

STM32 solution for using Sigfox is actually one of the best offer on the market has the solution is powerful, low consumption and allows global coverage with the use of the last Sigfox library versions including Monarq, Bubble… Different module providers are actually designing solutions based on this platform.

In this post we are going to see how to configure the STM32 platform, starting from a STM32L053 devkit plus a S2LP extension. Using a eclipse/gcc environment. The environment installation is described in this post about installing Eclipse for STM32.

As usual, if making a sample with Keil you don’t master a bit is easy, getting the right working configuration you can reproduce in an industrial way in a clear code is a challenge with ST.

Create a fresh new project for Eclipse AC6 / STM32 environment

Thanks to CubeMX we can create a project for the STM32 devkit. Start CubeMX and select the right board.

First select the board selector tab then search for the Nucleo-L053R8 board and double click on the board in the list. This will create a project with the default setting for this devkit.

Once done you can click on the gearing icon to generate the project skeleton.

Give the project a name, select the Advanced structure (not mandatory) then select an Eclipse project target by selecting SW4STM32 toolchain.

Then you go on code Generator tab and select Generate peripheral initalization as par of .c/.h and select Set all free pins as analog

Then you go to Advanced Settings tab and check option to not generate function call for ADC.

You can save this project and open it into eclipse AC6.

Test this with making a led blinking by editing the main.c file and add the following lines:

/* Infinite loop */
uint8_t led = GPIO_PIN_SET;
while (1)

  HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin,led);

Compile it by selecting the Release target and clicking on anchor icon. Once the hex file has been compiled launch the  STM32-STLink Utility, load the hex file and download it on the board. The green led should start blinking 5 times per seconds.

The full source code with hex file already compiled is accessible in the following GitHub repository with the STEP1 – xxx tag.

Incorporate the Sigfox library

The following elements detail the manual operation I’ve made (some may missing). If you do not have to make it from scratch because you want to use your own platform or change for another platform you can directly use the Github repository with the STEP2 – xxx tag.

This GitHub repository is using my STM32 SDK GitHub repository . This second repository needs to be cloned and the directory needs to imported as a Linked Folder to the previously cloned project.

The manual process looks like:

In the previous CubeMx we need to configure some peripherals for matching with the S2LP:

  • Enable SPI1 as Full-Duplex Master with Hw Nss Signal disabled
  • Enable TIM21 selecting clock source as Internal Clock.
  • Enable RTC by activating clock source
  • Enable ADC with Temp sensor
  • Enable IWDG
  • Enable USART2 (for logging @115200)
  • Enable SYSTICK

The global STM32 pinout configuration look like this

Gpio configuration is

Regenerate the project.

For having a working platform for transmitting Sigfox signal with STM32 and S2LP we need to deploy different layers of technical stacks:

The S2LP SDK can be obtained from this link it contains the libraries for S2LP and Sigfox.

The Sigfox library is delivered as a compiled library with associated headers. It exists for the different device targets. The STM32L058 is based on a CortexM0+ the library to be used will be that one.

The Sigfox library is compiled and deliver 2 libraries:

  • SFX_LIB_FDLXXX_CM0+_GCC.a => the sigfox lib
  • SFX_ADDON_VERIFIED_FDLXXX_CM0+_GCC.a => supplemental functions for sigfox verified certification.

So, on the project we are going to add the Sigfox headers into Core>>Inc>>sigfox directory. And copy the SFX_LIB_FDLXXX_CM0+_GCC.a file into libSFX_LIB_FDLXXX_CM0+_GCC.a in the Drivers directory.

The Sigfox library is a high level library and to implement the radio level another library is required to pilot the ST-Microlectronics S2-LP chip. The library is provided for the different zones (RCZ) – ETSI, FCC, ARIB or for all the zone. This is this last version we are going to select and copy into the Drivers directory. The lib file ST_RF_LIB_ALL250_CM0+_GCC.a will be copied and renamed as  libST_RF_LIB_ALL250_CM0+_GCC.a into the Drivers directory.

A second library is provided for storing and accessing the Sigfox keys. This lib is in Middelwares/ST/Sigfox_STM32_Library/Lib/KeyRetriever the archive file ID_KEY_RETRIEVER250_CM0+_GCC.a will be copied and renamed with a lib prefix into the Driver directory.

For being loaded correctly during link edition, the library file may be renamed to start with lib prefix.

At end of project configuration we may have something like this:

Now we need to add the libraries in the compilation chain.

And also add the following Path as part of the default include path:


Now you can start to create your own program based on my sdk

Modify the main.c file

/* USER CODE BEGIN Includes */
#include <it_sdk/config.h>
#include <it_sdk/itsdk.h>
#include <it_sdk/logger/logger.h>
/* USER CODE END Includes */

/* Infinite loop */
while (1)
   /* USER CODE BEGIN 3 */

Create you own code

Create a project_main.c file with a such content:

#include <it_sdk/config.h>
#include <it_sdk/itsdk.h>
#include <it_sdk/time/time.h>
#include <it_sdk/logger/logger.h>
#include <it_sdk/sched/scheduler.h>
#include <it_sdk/statemachine/statemachine.h>
#include <it_sdk/sigfox/sigfox.h>
#include <it_sdk/eeprom/eeprom.h>

void project_setup() {
   log_info("Booting \r\n");
   // Setup the S2LP / Sigfox stack according to EEPROM config
   // or config.h file

   uint8_t f[4] = { 0,1,2,3 };
   uint8_t r[8] = {0};
   itdsk_sigfox_txrx_t ret;
   ret = itsdk_sigfox_sendFrame(
           f,                      // data to be sent
           4,                      // frame size 4B
           2,                      // 1 transmit + 2 repeats
           SIGFOX_SPEED_DEFAULT,   // default speed (100b) RCZ1
           SIGFOX_POWER_DEFAULT,   // default power (14dB) RCZ1
           SIGFOX_ENCRYPT_NONE,    // clear text payload
           true,                   // downlink requested
           r);                     // buffer for downlink response

void project_loop() {
  // Go to sleep mode and wake-up automatically on interrupt
  // or every 500ms

Now you can compile & go …


You can now customize this peace of code by changing the configuration in Core/Inc/it_sdk/config.h file and other config files in the same directory.

Related documentation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.