cancel
Showing results for 
Search instead for 
Did you mean: 

BLE + Vibration Detection

RB4
Associate II

I am trying to build a project to detect vibration using STEVAL PROTEUS 1 (STM32WB5MMG, ISM330DHCX and BLE SENSOR). Unfortunately my sensor and BLE does not initialize despite 0 errors.

I have used custom BLE Template. I have initialized sensor code in custom_app.c. 

My inference:

Below is the main.c function 

MX_APPE_Init();

 Custom_APP_Init();//

//  UTIL_SEQ_RegTask(1 << CFG_TASK_BLINK_LED_ID,

while (1)

{

   /* USER CODE END WHILE */

MX_APPE_Process();

   /* USER CODE BEGIN 3 */

// HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_2);

HAL_GPIO_WritePin(GPIOD, GPIO_PIN_2, SET);

HAL_Delay(100);

HAL_GPIO_WritePin(GPIOD, GPIO_PIN_2, RESET);

HAL_Delay(100);

}

/* USER CODE END 3 */

}

Here, the code works when I comment out MX_APP_Init() and MX_APPE_process() and i can see the LED toggle, LED constantly stays ON when I only comment out MX_App_Process() but that is not the dfesired outcome i want. I want my code to help me log vibration data via BLE, it is not happening since both BLE and Accelerometer are not working.

7 REPLIES 7
RB4
Associate II
 
FilipKremen
ST Employee

Hello,

in the main while loop, there should be only MX_APPE_Process() function for running the sequencer.

Please visit this topic below as it might be helpful for your application.

Sending sensor data via BLE - STMicroelectronics Community

Could you please provide more information what exactly doesn't work in your project?

Are you able to read any data from the sensors? (simple reading data app without STM32WPAN)

Is the code stuck anywhere? Can you please try to debug the project?

Thank you.

Best regards,

Filip Kremen

I am able to read data from sensor without any BLE connection (STM32WPAN).

But when I try to implement BLE with Sensor Logic I am unable to make a working vibration detection project.

Board is not visible on sensor app and the led is supposed to initialize when sensor turns on , that is not happening either.

 

I have already tried out this approach. It is not working. Also I have shared my project (zip folder) with you previously.

There is only a single function in while loop as you have mentioned. 

My project is specifically for Vibration Detection and BLE connection.

MX_APPE_Init();

while(1){

MX_APPE_Process();

}

while testing if our code works I found that when LedToggle code logic is placed in while loop and MX_APPE_Init() and MX_APPE_Process() functions are commented out the ledToggle code works.

And when I comment out only MX_APPE_Process() Led is turned on with no toggle and no led is on when both functions are as mentioned as above.

My inference is that MX_APPE_process is going into error handler(), which is why the loop isnt working.

The primary problem of BLE is still not working, nothing is visible on BLE classic app.

FilipKremen
ST Employee

I think root of the problem is that BLE isn't properly initialized yet.

Firstly, function APP_BLE_Init() must be called before adding any services or characteristics.

You have to wait for the SHCI_SUB_EVT_CODE_READY event to be able to work with BLE stack.

Please read the document below for more information.

How to build wireless applications with STM32WB MCUs - Application note

If you need further help, please don't hesitate to ask.

Best regards,

Filip Kremen

 

Hey, I tried out this approach but it is throwing multiple errors and upon resolving them, I am still unable to connect to bluetooth.

FilipKremen
ST Employee

Hello,

can you please describe the errors more in detail?

Also, could you please send me the modified project again?

Thank you.

Best regards,

Filip Kremen