Bosch Sensortec Community

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

    Cortex-M4 garbage sensor data with BME680

    Cortex-M4 garbage sensor data with BME680

    itsmaxdd
    Member

    Hello everyone,

    i'm looking to make the BME680 work with my setup before moving to BSEC library.
    Basically i'm facing an issue (probably integration) which is driving me crazy, namely i can't read the data from the sensor itself.

    Here is the output:

    BME680
    bme680_init done: 0
    bme680.chip_id: 0x61
    bme680_set_sensor_settings done: 0
    bme680_set_sensor_mode done: 0
    T: -231.30 degC, P: 27790966.00 hPa, H 2779096.50 %rH
    T: -231.30 degC, P: 27790966.00 hPa, H 2779096.50 %rH
    T: -231.30 degC, P: 27790966.00 hPa, H 2779096.50 %rH
    T: -231.30 degC, P: 27790966.00 hPa, H 2779096.50 %rH
    T: -231.30 degC, P: 27790966.00 hPa, H 2779096.50 %rH
    T: -231.30 degC, P: 27790966.00 hPa, H 2779096.50 %rH
    T: -231.30 degC, P: 27790966.00 hPa, H 2779096.50 %rH
    T: -231.30 degC, P: 27790966.00 hPa, H 2779096.50 %rH
    T: -231.30 degC, P: 27790966.00 hPa, H 2779096.50 %rH
    T: -231.30 degC, P: 27790966.00 hPa, H 2779096.50 %rH

    In the link below you can find the "main" code

    https://pastebin.com/urcZ0MaZ

    Here the i2c implementation

    https://pastebin.com/dL4ZVd10

    Can anyone help me out in finding the problem?

    Regards,

    4 REPLIES 4

    itsmaxdd
    Member

    I corrected the "len+1" bug in the user_i2c_write. Stupid mistake on my side.

    Still the sensor data "accuracy" for temperature is kinda low in the sense that temperature is wrong by almost 8 degrees.

    Can i assume it is due to the  pcb heating ? Should i use the sensor offset for compensation?

    BME680
    bme680_init done: 0
    bme680.chip_id: 0x61
    bme680_set_sensor_settings done: 0
    bme680_set_sensor_mode done: 0
    T: 27.25 degC, P: 999.03 hPa, H 41.96 %rH , G: 205250 ohms
    T: 27.68 degC, P: 999.03 hPa, H 42.32 %rH , G: 226416 ohms
    T: 28.04 degC, P: 998.96 hPa, H 42.09 %rH , G: 232654 ohms
    T: 28.31 degC, P: 998.98 hPa, H 41.82 %rH , G: 238207 ohms
    T: 28.54 degC, P: 998.98 hPa, H 41.60 %rH , G: 240292 ohms
    T: 28.70 degC, P: 998.98 hPa, H 41.41 %rH , G: 242058 ohms
    T: 28.84 degC, P: 998.98 hPa, H 41.28 %rH , G: 245670 ohms
    T: 28.93 degC, P: 998.96 hPa, H 41.20 %rH , G: 246405 ohms
    T: 29.00 degC, P: 998.98 hPa, H 41.09 %rH , G: 246405 ohms
    T: 29.04 degC, P: 998.96 hPa, H 41.03 %rH , G: 248637 ohms

    Hi itsmaxdd,

    Which data rate did you use for testing ? The hot plate inside BME680 operates at ~300-400 degrees celsius. When using the ULP mode (300 seconds interval), self-heating is not an issue.

    In LP mode (3 seconds interval), BSEC compensates for the self-heating of the sensor. The rest is a combination of the sensor offset and self-heating from your PCB.

    o_o

    Hello,

    i agree since i've started to use BSEC as well the compensation seems to be fairly decent.

    I'm now facing a different problem which is about the "state" thing.

    This is the ouput of my read_eeprom() where i actually read its content and where i return the length i read

    Initializing bsec
    config_load n_buffer: 454
    4 7 4 1 61 0 0 0 0 0 0 0 115 0 0 0 45 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 44 1 20 20 0 0 0 0 0 0 0 0 0 0 3 0 23 168 95 63 20 12 0 2 0 0 0 200 65 0 0 200 65 16 0 3 0 0 0 128 64 0 0 160 65 0 0 64 66 22 0 5 0 0 0 0 64 0 0 0 0 0 0 0 0 0 0 0 80 1 0 12 0 9 0 0 0 0 64 0 0 0 0 8 0 10 0 0 0 160 65 0 0 0 0 0 0 0 0
    bme680_status: 0
    bsec_status: -36

    The read function is as follow

    if (flash_drv_read(fl_dev, state_buffer, n_buffer, initial_address + 0x2D) == WM_SUCCESS){
    		flash_drv_close(fl_dev);
    		int k;
    		uint16_t length = 0;
    		for(k=0;k<n_buffer && state_buffer[k] != 0xFF;k++){
    			length++;
    			wmprintf("%d ",state_buffer[k]);
    		}
    		wmprintf("\r\n");
    		return length;
    	}

    While the write function is as follow

    void state_save(const uint8_t *state_buffer, uint32_t length)
    {
    	flash_desc_t fl;
    	part_get_desc_from_name("ed_data", &fl);
    	uint32_t initial_address = fl.fl_start+fl.fl_size;
    
    	mdev_t *fl_dev = flash_drv_open(FL_INT);
    	if (fl_dev != NULL) {
    		//initial_data_address - 0x1000 + 0x2D
    		flash_drv_write(fl_dev, state_buffer, length, initial_address + 0x2D);
    	}
    	flash_drv_close(fl_dev);
    }

    As you can see my API is not reporting me the read bytes so i had to calculate it.
    Fortuantely the EEPROM is 0xFF so i can check against that.

    Why do i receive error BSEC_E_CONFIG_CRCMISMATCH ? I don't think im reading from the wrong place

    Had to erase the eeprom first, solved

    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