Bosch Sensortec Community

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

    BME860 does not return humidity or gas-resistance

    Crackl1ng
    Member

    BME860 does not return humidity or gas-resistance

    Hello Bosch-Community,

     

    I'm using the BME860 with an STM32 board via I2C. Reading temperature and pressure seems to work fine, as its values seem to make sense.

    Crackl1ng_0-1636462135590.png

    But neither humidity nor gas_resistance or humidity change. Humidity also is the wrong number, since 100 % relative humidity is a little bit over the tops.

    I'm using the code, which is pretty similair to the one in the application note.

     

    float volatile temperature = 0;
    float volatile pressure = 0;
    float volatile humidity = 0;
    float gas_resistance = 0;
    
    struct  bme680_dev  gas_sensor;
    
    gas_sensor.dev_id = BME680_I2C_ADDR_PRIMARY;
    
    gas_sensor.intf = BME680_I2C_INTF;
    	gas_sensor.read = bus_read;
    	gas_sensor.write = bus_write;
    	gas_sensor.delay_ms = HAL_Delay;
    	///* amb_temp can be set to 25 prior to configuring the gas sensor
    		//* or by performing a few temperature readings without operating the gas sensor.
    	//
    		//*/
    	gas_sensor.amb_temp = 25;
    
    
    	int8_t volatile rslt = BME680_OK;
    	bme680_init(&gas_sensor);
    
    
    
    
    struct  bme680_field_data data;
    
    
    
    	uint8_t set_required_settings;
    
    	/* Set the temperature, pressure and humidity settings */
    	gas_sensor.tph_sett.os_hum = BME680_OS_2X;//BME680_OS_2X;
    	gas_sensor.tph_sett.os_pres = BME680_OS_4X;//BME680_OS_4X;
    	gas_sensor.tph_sett.os_temp = BME680_OS_4X;//BME680_OS_4X;
    	gas_sensor.tph_sett.filter = BME680_FILTER_SIZE_3;//BME680_FILTER_SIZE_3;
    
    	/* Set the remaining gas sensor settings and link the heating profile */
    	gas_sensor.gas_sett.run_gas = BME680_ENABLE_GAS_MEAS;
    	/* Create a ramp heat waveform in 3 steps */
    	gas_sensor.gas_sett.heatr_temp = 320; /* degree Celsius */
    	gas_sensor.gas_sett.heatr_dur = 120; /* milliseconds */
    
    	/* Select the power mode */
    	/* Must be set before writing the sensor configuration */
    	gas_sensor.power_mode = BME680_FORCED_MODE; //BME680_SLEEP_MODE;//
    
    	/* Set the required sensor settings needed */
    	set_required_settings = BME680_OST_SEL | BME680_OSP_SEL | BME680_OSH_SEL | BME680_FILTER_SEL
    	| BME680_GAS_SENSOR_SEL;
    
    	/* Set the desired sensor configuration */
    	rslt = bme680_set_sensor_settings(set_required_settings,&gas_sensor);
    
    	/* Set the power mode */
    	rslt = bme680_set_sensor_mode(&gas_sensor);
    while(1)
    {
    			if (bme680_ticker > 500)
    			{
    				bme680_ticker = 0;
    
    				HAL_GPIO_TogglePin(LED_0_GPIO_Port, LED_0_Pin);
    
    				rslt = bme680_get_sensor_data(&data, &gas_sensor);
    				if(data.status & BME680_GASM_VALID_MSK){
    				temperature = data.temperature;
    				humidity = data.humidity;
    				pressure = data.pressure;
    				VOC = data.gas_resistance/1000; //Gasresistance in kohm
    				gas_sensor.amb_temp = temperature;
    				rslt = bme680_set_sensor_settings(set_required_settings,&gas_sensor);
    				}
    
    				if (gas_sensor.power_mode == BME680_FORCED_MODE) {
    					rslt = bme680_set_sensor_mode(&gas_sensor);
    
    				}
    }

     

    As I was also checking my logic analyzer, but I have no idea why it cannot find any values according to the humidity or gas_resistance.

    Crackl1ng_1-1636462447276.png

    Crackl1ng_0-1636462595769.png

    (One while loop, he retries multiple times)

    I'm thankful for any help!

     

    Sincerely Crackl1ng

    3 REPLIES 3
    BSTRobin
    Community Moderator

    Re: BME860 does not return humidity or gas-resistance

    Hello Crackl1ng,

    Attachement is reference code on STM32 for your reference.

     

    Crackl1ng
    Member

    Re: BME860 does not return humidity or gas-resistance

    Hello BSTRobin,

     

    I will try it out as soon as possible! Thank you very much for the fast reply.

     

    Edit: Thank you, worked just fine! 

    BSTRobin
    Community Moderator

    Re: BME860 does not return humidity or gas-resistance

    Welcome, Crackl1ng.

    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