Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BME 680 Using without BSEC Library

    BME 680 Using without BSEC Library

    Ruslan
    Member

    Hi. I am trying to use bme680 without BSEC library with stm32f103. I included bme api files. All things looks good but I found interesting moment that I cant understand.  For some days I recieved gas resistence from 5000 ohms to 15000 ohms. At this moment my part of source code was:

     

    led_on;
    // BME680 ---------------------------------------------------------------------//	
    bme680_port_init();	
    BME680_On;		 
    I2C_Port_Init(100000); // инит I2C на скорость 100 кГц
    delay_ms_tim(50);
    led_off;
    delay_ms_tim(450);	
    		
    // BME680 Sensor Initialisation
    gas_sensor.dev_id = 0xEC;
    gas_sensor.intf =  BME680_I2C_INTF;
    gas_sensor.read =  bus_read;
    gas_sensor.write = bus_write;
    gas_sensor.delay_ms = delay_ms_tim;  
    gas_sensor.amb_temp = 25;	
    #ifdef debug			
    UART1_Transmit_string("\n bme680_init..."); 
    #endif	
    rslt = bme680_init(&gas_sensor);
    			
    if (rslt != BME680_OK){
    			bme680_is_present = false;
          #ifdef debug	
          UART1_Transmit_string("\nBME680 not found"); 
          #endif	
          }
    			else{	
           bme680_is_present = true;
    			 #ifdef debug
           sprintf(uart_buf,"\nBME680 Init OK -> Chip ID 0x%x", gas_sensor.chip_id);  
           UART1_Transmit_string(uart_buf);
           #endif
    			 // Set the temperature, pressure and humidity settings 
    			 gas_sensor.tph_sett.os_hum = BME680_OS_1X;
    			 gas_sensor.tph_sett.os_pres = BME680_OS_16X;
    			 gas_sensor.tph_sett.os_temp = BME680_OS_2X;
    			 //gas_sensor.tph_sett.filter = 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;
    			 //gas_sensor.gas_sett.heatr_dur = 1000;
    			 // Create a ramp heat waveform in 3 steps 
    			 gas_sensor.gas_sett.heatr_temp = 320; // degree Celsius 
    			 gas_sensor.gas_sett.heatr_dur = 150; // milliseconds 
    
    			 // Устанавливаем режим принудительного измерения 
    			 // Must be set before writing the sensor configuration 
    			 gas_sensor.power_mode = BME680_FORCED_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 profile duration		
    			 //bme680_set_profile_dur(2000, &gas_sensor); // in ms
    								
    			 // Get the profile duration of the sensor 		
    			 bme680_get_profile_dur(&meas_period, &gas_sensor);
    			 #ifdef debug
    			 sprintf(uart_buf,"\nBME680 profile duration: %i ms", meas_period);  
    			 UART1_Transmit_string(uart_buf);
    			 #endif	
    
           // Set the desired sensor configuration 
           rslt = bme680_set_sensor_settings(set_required_settings, &gas_sensor);
               #ifdef debug
               //sprintf(uart_buf,"\nBME680 set settings -> %s", rslt ? "Error" : "Ok");  
               //UART1_Transmit_string(uart_buf);
               #endif
    					 
           // Set the power mode 
           rslt = bme680_set_sensor_mode(&gas_sensor);
               #ifdef debug
               //sprintf(uart_buf,"\nBME680 set forced mode -> %s", rslt ? "Error" : "Ok");  
               //UART1_Transmit_string(uart_buf);
    					 #endif
              			
    delay_ms_tim(meas_period); // Delay till BME680 measurement is ready 
    	
    rslt = bme680_get_sensor_data(&data, &gas_sensor);
    	
    #ifdef debug
    sprintf(uart_buf,"\n\nT: %.2f degC, P: %.2f mmHg, H %.2f %%rH ", data.temperature, data.pressure / 100.0f * 75 / 100, data.humidity );
    UART1_Transmit_string(uart_buf);
    #endif     

    With this code I had temperature readout less than real for 1C, humidity less than real for 15%. I am using 10 sec pause with standby mode after end of measurement. Then I decided to check for what purpose function bme680_set_profile_dur(2000, &gas_sensor).  After this changing now I have at start gas resistanse 35000 ohms and 1 hour later 25000 ohms. When I comment again bme680_set_profile_dur() function I still recieve gas resistance in 25000 - 35000 range and the same unreal T and H values. Can you tell me what is real range of resistance I must recieve in typical home room and why T and H values are wrong? How oversampling and filter settings affectc on measurements?

    10 REPLIES 10

    shellywang
    Occasional Contributor
    For temperature data, the absolute accuracy is ±1 degree, so from our side, the output of the temperature sensor is OK. For humidity sensor data, we recommend that you increase the humidity oversampling with the following settings. To read data in forced mode, you first need to set the sensor to forcemode. I recommend you use the API on github https://github.com/BoschSensortec/BME680_driver)

    handytech
    Community Moderator
    Community Moderator

    In general we can only strongly recommend to run BSEC together with the BME680, unless you have sufficient knowledge in MOX sensing technology to interpret raw sensor signals on your own.


    @Ruslan wrote:

    Can you tell me what is real range of resistance I must recieve in typical home room [...] ?


    Unfortunately we can't. Gas resistance values can vary from part to part, based on operating mode, and even environmental history. Anywhere from a few kΩ to a few MΩ are plausible outputs.


    @Ruslan wrote:

    With this code I had temperature readout less than real for 1C, humidity less than real for 15%. Can you tell me [...] why T and H values are wrong?


    This behavior doesn't sound expected. In a constant environment, a lower temperature read-out typically results in a higher relative humidity output. Note that since the internal temperature sensor is very sensitive, several factors may influence the raw temperature output, including from the sensor's heater configuration, as well as heat sources from other components on the PCB. If the self-heating of the device is predictable (e.g. close to constant constant offset), this can be compensated for in software.


    @Ruslan wrote:

    How oversampling and filter settings affectc on measurements?


    Oversampling can be used to reduce noise, at the expense of power consumption (and max. ODR available, although rarely relevant in BME680 use-cases). The built-in IIR filter can be used to suppress short-terms disturbances in the temperature and pressure signals. It effectively reduces the bandwidth/response-time of the temperature and pressure outputs.

    To add to what my colleague just said, I realized that selecting the right BSEC output is often asked, so I created a Q&A entry:
    https://community.bosch-sensortec.com/t5/Question-and-answers/BSEC-output-selection/qaq-p/9933#M97

    The effect of temperature and humidity are quite difficult to characterize, so I can only recommend all our customers use compensated gas resistance at a minimum.

    If we over simplify the BSEC software, in complexity layers:

    • Raw gas resistance
      • Compensate for humidity and temperature
    • Compensated gas resistance
      • Add baseline tracking algorithm
    • Static IAQ
      • Add sensitivity tracking algorithm
    • IAQ

     

    o_o

    Hi, I am again here and have some more questions. For about readings of temp, hum and pressure now I have real values and I am satisfied. But with gas readings I am confised. I wanted to use BSEC in my design but I can not. I am using stm32f103c8t6, it is in Standby mode nearly all the time. Device wakes up one time in 30 minutes, forces BME680 measurement, reads data and displays it on Electronic Paper Display and goes again to Standby mode where all mcu system stopped and only rtc is working. In this case I can not keep bsec calibration variables in ram. After wakining it starts program execution from begining. I only have 42pcs of  16-bit backup registers that are powered from rtc unit. Eight of them are engaged into my program. Is it enough 34 registers for BSEC(calibration)?  How I can use BSEC with this registers?  Now my algorithm without bsec is: after waking I assume ambient temperature to 23 degs. Than I make measurement(only TPH), measured temp is used for reinit of bme680 to measure gas resistance. Than read gas and display it.

    While testing device I set wake up time to 30 sec and through some stabilization time I have one gas resistance, but when I set 5 minutes interval I have another readings(all at same environment and after stabilization),  and readings are differ at times. Why it is so? Can it be because I make init of bme680 after wake up or I must do it only once(at mcu power up) and than after wake up only start measurements?

    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