Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BME280 reporting the same values

    Highlighted
    New Poster

    BME280 reporting the same values

    I am trying to get the temperature, pressure and humidity from the BME280 sensor through i2c but I am getting the same readings all the time:

    24.05 deg C, 632.83 hPa, 53.13%
    24.05 deg C, 632.83 hPa, 53.13%
    24.05 deg C, 632.83 hPa, 53.13%
    24.05 deg C, 632.83 hPa, 53.13%

    I read a similar problem from another user's post in this forum but, in that case, he had configured the interface as SPI instead of i2c but I have it correctly set.

    This is the sensor initialization code I am using:

     

    int8_t bme280_sensor_init(void)
    {
    dev.dev_id = BME280_I2C_ADDR_SEC; //BME280_I2C_ADDR_PRIM;
    dev.intf = BME280_I2C_INTF;
    dev.read = bme280_i2c_read;
    dev.write = bme280_i2c_write;
    dev.delay_ms = user_delay_ms;
    
    int8_t result = bme280_init(&dev);
    
    if(result != BME280_OK)
        return -1;
    
    // I tried both setting values with same result
    // dev.settings.osr_h = BME280_OVERSAMPLING_1X;
    // dev.settings.osr_p = BME280_OVERSAMPLING_16X;
    // dev.settings.osr_t = BME280_OVERSAMPLING_2X;
    // dev.settings.filter = BME280_FILTER_COEFF_16;
    dev.settings.osr_h = BME280_OVERSAMPLING_1X;
    dev.settings.osr_p = BME280_OVERSAMPLING_1X;
    dev.settings.osr_t = BME280_OVERSAMPLING_1X;
    dev.settings.filter = BME280_FILTER_COEFF_OFF;
    
    uint8_t settings_sel = BME280_OSR_PRESS_SEL | BME280_OSR_TEMP_SEL | BME280_OSR_HUM_SEL | BME280_FILTER_SEL;
    
    result = bme280_set_sensor_settings(settings_sel, &dev);
    
    if(result != BME280_OK)
        return -1;
    
    return 0;
    }

     

     

    This is the code I use to read the values:

     

    int8_t bme280_sensor_read(float *temp, float *press, float *hum)
    {
    	struct bme280_data comp_data;
        /* configure forced mode */
    	uint8_t result = bme280_set_sensor_mode(BME280_FORCED_MODE, &dev);
        if(result != BME280_OK)
        	return -1;
    
        /* wait for the measurements to complete */
        dev.delay_ms(1000);//40
    
        result = bme280_get_sensor_data(BME280_ALL, &comp_data, &dev);
        if(result != BME280_OK)
        	return -1;
    
        /* Read was ok, update values */
    #ifdef BME280_FLOAT_ENABLE
        *temp = comp_data.temperature;
        *press = 0.01 * comp_data.pressure;
        *hum = comp_data.humidity;
    #else
    #ifdef BME280_64BIT_ENABLE
        *temp = 0.01f * comp_data.temperature;
        *press = 0.0001f * comp_data.pressure;
        *hum = 1.0f / 1024.0f * comp_data.humidity;
    #else
        *temp = 0.01f * comp_data.temperature;  // USING THIS
        *press = 0.01f * comp_data.pressure;
        *hum = 1.0f / 1024.0f * comp_data.humidity;
    #endif
    #endif
    
        return 0;
    
    }

     

     

    In bme280_defs.h file I have commented out the BME280_64BIT_ENABLE definition:

     

    #ifndef BME280_FLOAT_ENABLE
    
    /* #define BME280_FLOAT_ENABLE */
    #endif
    
    #ifndef BME280_FLOAT_ENABLE
    #ifndef BME280_64BIT_ENABLE
    //#define BME280_64BIT_ENABLE
    #endif
    #endif

     

     

    Am I missing something? any help or tip about how to procceed ?

     

    Thanks,

    Javi

     

    EDIT:

    Just in case it helps, I have added some debug traces in the read and write callbacks. I print the device addres, register address, register data, length and, in case of a read, the bytes read

     

    Initializating I2C
    [R] 0x77 0xD0 0x60 01: 60
    [W] 0x77 0xE0 0xB6 01
    [R] 0x77 0xF3 0x00 01: 00
    [R] 0x77 0x88 0x2C 26: 2C 6D 30 66 32 00 F8 8D 16 D6 D0 0B DF 25 2D FF F9 FF 0C 30 20 D1 88 13 00 4B
    [R] 0x77 0xE1 0x5B 07: 5B 01 00 16 23 03 1E
    [R] 0x77 0xF4 0xEC 01: EC
    [W] 0x77 0xF2 0x01 01
    [R] 0x77 0xF4 0xEC 01: EC
    [W] 0x77 0xF4 0xEC 01
    [R] 0x77 0xF4 0xE4 01: E4
    [W] 0x77 0xF4 0x24 01
    [R] 0x77 0xF5 0xFC 01: FC
    [W] 0x77 0xF5 0xE0 01
    Setting forced mode
    [R] 0x77 0xF4 0xDC 01: DC
    [R] 0x77 0xF4 0xDC 01: DC
    [W] 0x77 0xF4 0xDD 01
    Getting sensor data
    [R] 0x77 0xF7 0x80 08: 80 00 00 80 00 00 80 00
    24.05 deg C, 632.83 hPa, 53.13%

     

    2 REPLIES 2
    New Poster

    Re: BME280 reporting the same values

    Just in case it helps to someone with the same problem, I implemented the 2.0.5 version of the BME280 driver and it worked fine. 

    Community Moderator
    Community Moderator

    Re: BME280 reporting the same values

    Thanks for reporting !
    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