Important Cookie Information

This website uses absolutely necessary cookies. If you consent to the use of convenience cookies, please click “Yes, I agree.” By clicking on “Privacy Settings.” you can change this setting at any time and withdraw your given consent. Icon down see more You can find detailled information in our Privacy Policy Icon forward-right
Icon up see less

Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BME 680 BSEC library humidity is 100 its not varying,returning wrong values

    New Poster

    BME 680 BSEC library humidity is 100 its not varying,returning wrong values

    We are  using STM32F091 controller .Used BSEC_1.4.7.2_Generic_Release_20190122\algo\bin\Normal_version\gcc\Cortex_M0 library.

    config and previous state are  not saved in  volatile memory ,we were just returing 0 in the return statement of that function.

    We are getting the following readings .

    Temp: 32  Humi: 100  Press: 91679  IAQ: 0  GAS:0

    Temp: 32  Humi: 100  Press: 91679  IAQ: 0  GAS:0

    Temp: 32  Humi: 100  Press: 91681  IAQ: 0  GAS:0

    Temp: 32  Humi: 100  Press: 91681  IAQ: 0  GAS:0

    Temp: 32  Humi: 100  Press: 91683  IAQ: 0  GAS:0

    Temp: 32  Humi: 100  Press: 91683  IAQ: 0  GAS:0

    Temp: 32  Humi: 100  Press: 91684  IAQ: 0  GAS:0

    Tags (2)
    3 REPLIES 3
    Member

    Re: BME 680 BSEC library humidity is 100 its not varying,returning wrong values

    Hello,

    I faced a 'similar ' problem but with esp8266. The problem was on my side and was on the way I  coded the i2c read and write functions.

    I was using some i2c functions which was working for bme280 and reused them for bme680 thinking they will work, but they don't.

    So my advice would be to check that you read and write data through i2c as specified by Bosch for BME680.

     

     

    New Poster

    Re: BME 680 BSEC library humidity is 100 its not varying,returning wrong values

    Hi Ochrin,

    Thank you for reply.

    But both BME280 and BME680 I2C frames are same.

    I have used the following function for I2C read and write .Please let me know if any changes to be made in this.


    /*!
    * @brief Write operation in either I2C or SPI
    *
    * param[in] dev_addr I2C or SPI device address
    * param[in] reg_addr register address
    * param[in] reg_data_ptr pointer to the data to be written
    * param[in] data_len number of bytes to be written
    *
    * @return result of the bus communication function
    */
    int8_t bus_write(uint8_t dev_addr, uint8_t reg_addr, uint8_t *reg_data_ptr, uint16_t data_len)
    { int8_t rslt=0;
    // ...
    // Please insert system specific function to write to the bus where BME680 is connected
    // ...

    HAL_StatusTypeDef status = HAL_OK;
    rslt = 0;

    while (HAL_I2C_IsDeviceReady(&hi2c1, (uint8_t)(dev_addr<<1), 3, 100) != HAL_OK) {}

    status = HAL_I2C_Mem_Write(&hi2c1, // i2c handle
    (uint8_t)(dev_addr<<1), // i2c address, left aligned
    (uint8_t)reg_addr, // register address
    I2C_MEMADD_SIZE_8BIT, // bme680 uses 8bit register addresses
    (uint8_t*)(&reg_data_ptr), // write returned data to reg_data
    data_len, // write how many bytes
    100); // timeout

    if (status != HAL_OK)
    {
    // The BME680 API calls for 0 return value as a success, and -1 returned as failure
    rslt = (-1);
    }

    return rslt;
    }

     

     

    /*!
    * @brief Read operation in either I2C or SPI
    *
    * param[in] dev_addr I2C or SPI device address
    * param[in] reg_addr register address
    * param[out] reg_data_ptr pointer to the memory to be used to store the read data
    * param[in] data_len number of bytes to be read
    *
    * @return result of the bus communication function
    */
    int8_t bus_read(uint8_t dev_addr, uint8_t reg_addr, uint8_t *reg_data_ptr, uint16_t data_len)
    {
    int8_t rslt=0;
    HAL_StatusTypeDef status = HAL_OK;
    rslt = 0;
    uint8_t array[28] = {0};
    uint8_t stringpos = 0;
    array[0] = reg_addr;

    while (HAL_I2C_IsDeviceReady(&hi2c1, (uint16_t)(dev_addr<<1), 3, 100) != HAL_OK) {}

    status = HAL_I2C_Mem_Read(&hi2c1, // i2c handle
    (uint8_t)(dev_addr<<1), // i2c address, left aligned
    (uint8_t)reg_addr, // register address
    I2C_MEMADD_SIZE_8BIT, // bme680 uses 8bit register addresses
    (uint8_t*)(&array), // write returned data to this variable
    data_len, // how many bytes to expect returned
    100); // timeout

    if (status != HAL_OK)
    {
    // The BME680 API calls for 0 return value as a success, and -1 returned as failure
    rslt = (-1);
    }
    for (stringpos = 0; stringpos < data_len; stringpos++) {
    *(reg_data_ptr + stringpos) = array[stringpos];
    }


    return rslt;
    }

    Highlighted
    Member

    Re: BME 680 BSEC library humidity is 100 its not varying,returning wrong values

    Ok, but you should check exactly what functions HAL_I2C_Mem_Read() et HAL_I2C_Mem_Write() are doing...

    And yes, you are right I2C functions for bme280 and bme680 are identical.

    I guess I did something wrong in coding these functions for bme280 and despite it was anyway working but not anymore when using bme680. And I think my error came from the bme280 data sheet where multiple writes are coded like:

    slave address, reg address, reg data, reg address, reg data, reg address, reg data, ...

    But you should implement:

    slave address, reg address, reg data, reg data, reg data, ...

    Hope it helps...

     

     

    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