2025-06-23 8:17 AM
P-Nucleo STM32WB55
I have two 3-axis accelerometers & toe temperature sensors on an I2C bus. I taking measurements at 1 Hz.
I would like to send this data over BLE. Every tutorial so far seems to skip how to read the data into a characteristic & then send it. At this point I am only interested in broadcasting.
I've managed to set up an attribute for reading, given the service its names. I can see the device & the service advertised on my phone via ST's BLE app. So how do I get the data into the service?
I'm going around in circles here!!
Please no "have you looked at the examples", yes I have they aren't making any sense to me, I need to talk to a human about this.
2025-06-24 6:03 AM
Hello,
for your use case, I think BLE_HeartRate example would be a good reference project.
In this example there is a sensor measurement simulation. If you open hrs_app.c file, you can see there HRSAPP_Init() function. The first function registers the measurement task in the sequencer.
(You can find more information about sequencer here Utility:Sequencer - stm32mcu) It's a basically scheduler for tasks. Once the task is registered in the sequencer, it can be run from sequencer. The function HRSAPP_Measurement() is getting value from sensor (in this case reading from RTC) and then it
UTIL_SEQ_RegTask( 1<< CFG_TASK_MEAS_REQ_ID, UTIL_SEQ_RFU, HRSAPP_Measurement );
updates the characteristic value with this function below.
HRS_UpdateChar(HEART_RATE_MEASURMENT_UUID, (uint8_t *)&HRSAPP_Context.MeasurementvalueChar);
Now when you have the function for measuring the values and writing into the characteristic, it can be called periodically with timerservers. The code below creates a timer which is triggered periodically, and it runs the measurement.
HW_TS_Create(CFG_TIM_PROC_ID_ISR, &(HRSAPP_Context.TimerMeasurement_Id), hw_ts_Repeated, HrMeas);
You can start the timer to run periodically with HRSAPP_MEASUREMENT_INTERVAL with this function below.
HW_TS_Start(HRSAPP_Context.TimerMeasureHRSAPP_MEASUREMENT_INTERVALment_Id, HRSAPP_MEASUREMENT_INTERVAL);
I strongly recommend having a look at the links below to better understand.
How to build wireless applications with STM32WB MCUs - Application note
STM32WB Getting Started Series - YouTube
If you need to explain any step, please don't hesitate to ask.
Best regards,
Filip Kremen
2025-06-25 3:18 AM
Well I would look at the example but the "Example Selector" just keeps crashing CubeIDE
2025-06-25 3:39 AM
Hello,
please try to open the example directly from Windows explorer.
Best regards,
Filip Kremen
2025-06-25 5:19 AM
Hmmm now the board doesn't show when using either ST BLE Toolbox or ST BLE Sensor.
Previously the board would show up but now I've flashed with the HRS example its not showing.
2025-06-25 5:25 AM
Do you see any BLE traces when you open terminal?
Probably FUS is running there instead of wireless FW. Please open STM32CubeProgrammer and press the "Start Wireless Stack" button and then upload the example again.
STM32WB Firmware Upgrade Service - stm32mcu
Best regards,
Filip Kremen
2025-06-25 5:46 AM
No BLE traces.
Opened STM32CubeProgrammer and pressed "Start Wireless Stack" button and then uploaded the example again, still not showing.
When I upload my own code I can see the device (although confusingly not when I enable the ST device filters?!?!).
Honestly I just want to be able to broadcast the data. The heart rate monitor code (even if it worked) seems overly complex & nested/cryptic. Surely there's an easier way than all that abstraction?
2025-06-25 6:06 AM
You can enable the debug traces as mentioned here. (4.6)
STM32WB Bluetooth® LE – Heart Rate Sensor Project - stm32mcu
Also, please try to debug the project if it is stuck somewhere.
If you want to broadcast only, possibly BLE_Beacon example could be a better choice.
STM32WBA Bluetooth® Low Energy – Beacon - stm32mcu
Best regards,
Filip Kremen
2025-06-25 6:44 AM - edited 2025-06-25 6:46 AM
Sorry but this is still really opaque. As I've tried to explain since the OP, there is so much redirection & abstraction going on with the examples I just cant find an answer to my question in them. Even the way the projects are structured is unintuitive (e.g the includes hidden away in the binaries folder? who does that?)
I am happy to generate my own scheduling, I just need to know how to load the BLE package with data & transmit it! This is completely opaque in the examples (which dont work & for which the YouTube videos are years out of date).
2025-06-25 7:27 AM
I agree that it might look complicated at first time.
Have you watched the STM32WB getting started series on YT that I sent you?
It's useful to watch it for better overview and there is also a video regarding sending the data.
Also, if you could share your project, I could help you further with your application.
Best regards,
Filip Kremen