2025-01-02 01:07 AM
Hello Everyone,
I have been working in a project which reads a sensor data (Lets say an integer) continuously inside a while loop, something similar to following. I am using STM32WB55RG Nucleo Board with wireless connectivity.
void getReading(int *variable) {
while (1) { // Infinite loop
(*variable)++; // Increment the variable
if (*variable == 1000) { // Check if it reaches 1000
*variable = 0; // Reset to 0
//printf("Variable reset to 0\n");
} else {
//printf("Variable updated: %d\n", *variable);
}
}
}
My goal is to send this sensor reading to a mobile phone over BLE, I followed the tutorial given in STM webpage to control a LED using STM BLE Toolbox application. However i am wondering how to modify that project to fulfill my requirement. It seems like the code being generated by CubeMx application is quite complex for a beginner and needs knowledge about sequencers and so on. Are there any simple method for this task? or How can I modify the BLE_Custom code generated by CubeMX for my application?
Thanks in Advance!!
2025-01-02 02:08 AM
Hello @Kavindu_Shehan
You just have to add create this function, create a task that execute it on the sequencer of your app and call this function to update this variable. After that, you can send the updated value throw BLE. For that, you can refer to the BLE_HeartRate application that do really a similar function.
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-01-02 05:17 AM
It would be grateful I you can provide an example code snippet for me.
Thanks.
2025-01-02 05:24 AM
It is not just a snippet code. You should create a full project and create a function that receive the data from sensor then send it to the BLE mobile app. Studying deeply the example I've provided will help you to understand how to do that. Also, AN5289 can help you to understand the necessary parts of the BLE project.
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-01-02 05:44 AM
Well, asked this question in this forum after following tons of tutorials and application notes for days. Looked for a direct solution.