Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Blocking behavior when intergrating BME688 to Nucleo board

    Blocking behavior when intergrating BME688 to Nucleo board

    huytyskland
    Member

    Hello everyone,

    Currently, I am working with an IoT application on the board Nucleo-WL55JC1 with the sensor BME688. The example I am using is LoRaWAN_End_Node downloaded from STM32Cube MX. 

    What I did: I initialized the the BME688 and set up some configuration after the initialization of MX_LoRaWAN_Init(). I, then, set up some configuration outside the while loop. I "extern"ed the variables below so that I can used them elsewhere:

    struct bme68x_dev bme;
    struct bme68x_conf conf;
    struct bme68x_heatr_conf heatr_conf;

    Order of initialization are below:

      /* Initialize all configured peripherals */
      MX_GPIO_Init();
      MX_LoRaWAN_Init();
      MX_I2C3_Init();
      /* USER CODE BEGIN 2 */
      int8_t rslt = bme68x_interface_init(&bme, BME68X_I2C_INTF);
      //bme68x_check_rslt("bme68x_interface_init", rslt);
          // UART_Transmit_IT("/init\n");
      rslt = bme68x_init(&bme);
    
      //Set up the measurement
      conf.filter = BME68X_FILTER_OFF;
      conf.odr = BME68X_ODR_NONE;
      conf.os_hum = BME68X_OS_16X;
      conf.os_pres = BME68X_OS_1X;
      conf.os_temp = BME68X_OS_2X;
      rslt = bme68x_set_conf(&conf, &bme);
    
      heatr_conf.enable = BME68X_ENABLE;
      heatr_conf.heatr_temp = 300;
      heatr_conf.heatr_dur = 100;
      rslt = bme68x_set_heatr_conf(BME68X_SEQUENTIAL_MODE, &heatr_conf, &bme);
    
      rslt = bme68x_set_op_mode(BME68X_SEQUENTIAL_MODE, &bme);

    For obtaining the temperature/pressure/humidity/gas level, I got the data of the sensor in the function SendTxData in the file lora_app.c:

      struct bme68x_data data;
      uint32_t del_period;
      uint8_t n_fields;
    
    #ifdef CAYENNE_LPP
      uint8_t channel = 0;
    #else
      uint16_t pressure = 0;
      int16_t temperature = 0;
      uint16_t humidity = 0;
      uint32_t i = 0;
      int32_t latitude = 0;
      int32_t longitude = 0;
      uint16_t altitudeGps = 0;
    #endif /* CAYENNE_LPP */
    
      //EnvSensors_Read(&sensor_data);
      del_period = bme68x_get_meas_dur(BME68X_SEQUENTIAL_MODE, &conf, &bme) + (heatr_conf.heatr_dur * 1000);
      bme.delay_us(del_period, bme.intf_ptr);
      int8_t rslt = bme68x_get_data(BME68X_SEQUENTIAL_MODE, &data, &n_fields, &bme);
      float senTemp = data.temperature;
      float senPres = data.pressure;
      float senHumid = data.humidity;

    The problem: as in the code, I set the sensor to work in sequential mode, however, the whole setup stopped working after the first measurement. The same thing happened when I set the sensor to work in parallel mode. Sleep mode worked okay and for Forced mode, I could achieve the first measurement before the sensor turned to sleep mode (correct).

    huytyskland_0-1662569056243.png

    (the end device started the first measurement and stopped at that point).

    Question: Where should I start tracking the problem or how do I fix this problem?

    I hope to have responses from you.

    Thank you very much, Huy Nguyen.

     

    5 REPLIES 5

    BSTRobin
    Community Moderator
    Community Moderator

    Hi huytyskland,

    Force mode, parallel mode, sequential mode example run well on STM32F4, you could refer attached example code on STM32F4, log files.

    Hello @BSTRobin 

    Thank you for your response. Right now I can intergrate BME688 to the my board and use it to measure temperature/gas/pressure/humidity with no difficulty at all. However, the software for that system runs only the BME688 related tasks.

    My issue occured when I implemented the code of BME688 (the code that I took from my previously mentioned system - This code refered from both F4 example and this example) into an project of my board (LoRaWAN_End_Node project written by STM developers). The issue happened. So I think one of them blocked each other and stopped the program from continuing.

     

    Kind regards, Huy Nguyen.

    BSTRobin
    Community Moderator
    Community Moderator

    Hi huytyskland,

    This is your system task scheduling problem. As you can see, the BME688 example code itself works normally. You need to adjust the scheduling of software on your MCU platform.

    Hello Robin,

    Thank you for your response. I figure that the system in LoRaWAN_End_Node example operates based on tasks. From that, I plan to divide the operation of BME688 into 2 tasks: 1 task for BME688 initialization, 1 task for obtaining sensor data.

    The task of initialization is:

    int8_t rslt = bme68x_interface_init(&bme, BME68X_I2C_INTF);
      //bme68x_check_rslt("bme68x_interface_init", rslt);
          // UART_Transmit_IT("/init\n");
      rslt = bme68x_init(&bme);
    
      //Set up the measurement
      conf.filter = BME68X_FILTER_OFF;
      conf.odr = BME68X_ODR_NONE;
      conf.os_hum = BME68X_OS_16X;
      conf.os_pres = BME68X_OS_1X;
      conf.os_temp = BME68X_OS_2X;
      rslt = bme68x_set_conf(&conf, &bme);
    
      heatr_conf.enable = BME68X_ENABLE;
      heatr_conf.heatr_temp = 300;
      heatr_conf.heatr_dur = 100;
      rslt = bme68x_set_heatr_conf(BME68X_SEQUENTIAL_MODE, &heatr_conf, &bme);
    
      rslt = bme68x_set_op_mode(BME68X_SEQUENTIAL_MODE, &bme);

    The task of data obtaining:

    	struct bme68x_data data;
    	uint32_t del_period;
    	uint8_t n_fields;
    	del_period = bme68x_get_meas_dur(BME68X_SEQUENTIAL_MODE, &conf, &bme) + (heatr_conf.heatr_dur * 1000);
    	bme.delay_us(del_period, bme.intf_ptr);
    	int8_t rslt = bme68x_get_data(BME68X_SEQUENTIAL_MODE, &data, &n_fields, &bme);
    	senTemp = data.temperature;
    	senPres = data.pressure;
    	senHumid = data.humidity;
    	senGas = data.gas_resistance;

    Do you think these 2 tasks can cover the operation of BME688 or I need more?

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist