Skip to main content
Associate II
November 27, 2024
Solved

Data transfer via BLE to mobile app

  • November 27, 2024
  • 4 replies
  • 2464 views

I'm working on sensor data transfer via BLE to mobile app (like nrf connect). My STM32WB board gets connected with the app, but the data is not transmitted. When I give functions in the main while loop for transmitting, it stop the device advertisement at mobile app. How to transfer the data to mobile app? I need to send continuous sensor data to mobile app.
I've also tested timer function as well. But still, it's impossible for me to transfer the data. 

I'm attaching the image of mobile app connection, there you can see that the value is 0. There, I need sensor data to be printed.
Can anyone help me to resolve this issue? Thanks in advance!

Best answer by STTwo-32

Hello @barathi_0206 

I suggest you to take a look at this application and compare it to your configuration. It should be really helpful.

Dont forget to read the readme file of this project and take a look at the wiki pages mentionned there. It should be helpful too.

Best Regards.

STTwo-32 

4 replies

STTwo-32
STTwo-32Best answer
Technical Moderator
November 27, 2024

Hello @barathi_0206 

I suggest you to take a look at this application and compare it to your configuration. It should be really helpful.

Dont forget to read the readme file of this project and take a look at the wiki pages mentionned there. It should be helpful too.

Best Regards.

STTwo-32 

Associate II
December 5, 2024

Thankyou @STTwo-32! It works. However it works for static continuous data. But with varying data (like from sensors), it doesn't receive it. In mobile app I receive data like 2E-16-00-00-00. I have also increased my UUID type into 128 bits. Still it receive like this. How to solve it?

 

Associate II
May 20, 2025

Hii Barathi_0206,
i am new with BLE can you help me with steps in stm32cube ide how to transmit and receive data through BLE,

 

Associate II
May 20, 2025

Hi @mihirsinha_ 

You can go through this wiki link for better understanding and practice this procedures. let me know if you need help at any particular areas.

Associate II
May 20, 2025

Thank you, Barathi_0206.
This will help me a lot. Actually, I already generated the code by following some tutorials, and I can see my device name on my mobile. But I want to send some data as well. Can you help me with the code where and what should I write to continuously send data like "Hello, World" for now?

Associate II
May 20, 2025

Try this for sending data via BLE to mobile app.

Associate II
May 21, 2025

Hi Barathi_0206,
Thanks for this tutorial — it's working!

Actually, what I'm working on involves using multiple ADCs with my mcu stm32wb55cgu6. Earlier, I was printing the data to the serial monitor via USB. Now, I want to use BLE instead of serial print. In main.c, I have done some calculations and all the initialization steps.

After using this tutorial, I saw that data is sent using a button press. But when I try to send the data directly from the main function, either it goes to the" void HardFault_Handler()" or the value is not advertised.

Associate II
May 22, 2025

Yes, I’ve faced this issue too. To resolve it, you should use a timer to handle your ADC readings. For continuous data transmission over BLE, go to custom_app.c and locate the Custom_YourCharacteristicName_Update_Char() function. This is where the BLE data gets updated.

Inside this function, you’ll find a line responsible for updating the characteristic value—comment that line out. Instead, move that line into your timer callback function. Then, simply call the timer callback from within the update function.

This approach worked for me, and I hope it helps you too!

Associate II
May 22, 2025

Thank you Barathi_0206,
it is working.
Will you help me with one more doubt? I also want to send commands through my mobile. Can you tell me where and how to store that command in a variable.