Showing results for 
Search instead for 
Did you mean: 

Simple BLE advertising application

Associate II

Hi there :waving_hand:

I am quite new to the topic of developing BLE hardware.

My goal of the current project is quite simple:

I have a custom board featuring stm32wb55ceu6 and a ambient temperature/humidity sensor.

All hooked up including the RF part with an impedance matching network to 50 ohms and an antenna for 2.4 GHz (BLE).

Now I would like to read the sensor using i2c and get the values for temp and humidity every let's say 10 minutes.

After getting the values I would like to just send out a ble advertisement containing the sensor data in bthome format (so that my home assistant can just read it).

There should be nothing else involved. The board is just sending out once every 10 minutes and after sending it goes back to sleep.

My question: can you maybe provide me a startingpoint where I can find information about BLE advertisement, etc.? 

I saw that there is a stm32wpan module but I am not sure if this is total overkill for this simple use case.

I am a bit lost with this :(

I was inspired by the following project:

And would like to build sth. Similar just with an stm32wb55.


Thank you 

ST Employee

Hi, there,
To begin with, here is an introductory page on the STM32WB and its environment:

From this page, you'll be able to find examples of projects similar to your use case. For example, the "BLE_Sensor" and "BLE_HealthThermometer" projects.

Best regards, 

Associate II

Hey Joe,

thanks for the answer. I was just checking out the example of the BLE_Sensor.

Am i right that advertising is happening in "app_ble.c" of this "WPAN" stack?

Found this here:


  ret = aci_gap_set_discoverable(ADV_IND,
                                 NO_WHITE_LIST_USE, /* use white list */
                                 (uint8_t*) &a_LocalName,


And then:

ret = aci_gap_update_adv_data(sizeof(a_ManufData), (uint8_t*) a_ManufData);

So i guess ManufData is containing the "raw" data which should be advertised?

I wanted to avoid using this whole GAP/GATT thingy. It seems to much for this usecase..

As an alternative i was seeing that there is an HCI - Interface which may is a shortcut to just do some advertising?


Would this also work somehow?

If you don't need to set up a connection, you can look at the BLE_Beacon example to make an ADV only.

Yes, if you don't want to use GAP commands as in the examples, you can use HCI commands.

Here's where you can find out more about these commands:

BR, Joé

Associate II

Thanks for the Answer Joe!

That helped me now and i am able to at least run the ble example app using clion.

So now i have the next question.

How would i solve the issue to change my advertising data from outside?

So i baked in the service data (hardcoded) in the class ibeacon_service.c the following:



  uint8_t service_data[21] =

          // 0xfcd2 - service UUID.

          // Service header - no encryption, bt home v2.

          // Temperature.
          0x02, // Type Flag (Temperature)

          0x44, // 21,16 Degrees
          0x08, // 21,16 Degrees

          // Humidity.
          0x2E, // Type Flag (Humidity)
          0x51, // 81% rel

          // Illuminance.
          0x05, // Type Flag (Illuminance)
          0x02, // 10,26 lx (LUX)
          0x04, // 10,26 lx (LUX)
          0x00, // 10,26 lx (LUX)

          // Battery voltage.
          0x0C, // Type Flag (Battery Voltage)
          0xA8, // 2,984 V
          0x0B, // 2,984 V

          // Soil moisture.
          0x2F, // Typeflag (moisture)
          0x30, // 48 %

          // Battery percentage.
          0x5C // 92%



This represents the BT Home format with static data.

Now i would like to update this data every 10 minutes (so i guess i need a timer somewhere).

Am i supposed to do this update from my main.c? Or from where i should update it?

So the flow is the following:

Device Boots -> Starts Advertising for 2 seconds -> Stop Advertising -> Then goes to deep sleep -> 10 minutes of sleep -> Wake up -> Advertising for 2 seconds ... -> repeat indefinitly this cycle.