Interfacing Bosch BME680

Hi,

I am trying the sample code in this regard. I have changed the I2C pins in the overllay file and bme register address to 0x77 as follows. It seems working but I have many questions.

&i2c0 {
	compatible = "nordic,nrf-twi";
	status = "okay";
	bme680: bme680@77 {
		compatible = "bosch,bme680";
		label = "BME680";
		reg = <0x77>;
	};
};

1. I think this is using the Zephyr built in bme680 driver, isn't it?

2. I am evaluating both BME680 and BME688.  How can I change code to suit BME688?

3. My case is a battery powered sensor, so I have to make it as much power efficient as possible. The sample program doesnt seem to meet that goal. I tried commenting out each channel and it doesn't seem that affect the power consumption.  I tried using 'sensor_sample_fetch_chan (dev, SENSOR_CHAN_AMBIENT_TEMP) just to fetch temp channel, but still same. Any idea why?

4. I want to read/write registers of the sensor, but Sensor API doesn't seem to provide any interface. How can I do  this?

Cheers,

Kaushalya

Parents
  • Hello, 

    Both sensors have been in use in our samples and prototyping platforms Thingy:53 and Thingy:91. What version of our SDK are you using? The information below is based on nRF Connect SDK v2.8.0.

    1. I think this is using the Zephyr built in bme680 driver, isn't it?

    Yes, looking at zephyr\boards\nordic\thingy53\thingy53_nrf5340_common.dtsi

    &i2c1 {
    	compatible = "nordic,nrf-twim";
    	status = "okay";
    	clock-frequency = <I2C_BITRATE_FAST>;
    
    	pinctrl-0 = <&i2c1_default>;
    	pinctrl-1 = <&i2c1_sleep>;
    	pinctrl-names = "default", "sleep";
    	bmm150: bmm150@10 {
    		compatible = "bosch,bmm150";
    		reg = <0x10>;
    	};
    
    	bh1749: bh1749@38 {
    		compatible = "rohm,bh1749";
    		reg = <0x38>;
    		int-gpios = <&gpio1 5 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    	};
    
    	bme688: bme688@76 {
    		compatible = "bosch,bme680";
    		reg = <0x76>;
    	};
    };

    2. I am evaluating both BME680 and BME688.  How can I change code to suit BME688?

    Have a the look at the BME68x: Gas sensor sample. This supports both sensors. You can also have a look the samples in our SDK that uses these sensors i.e. the sensor module in Asset Tracker v2 or the Bluetooth Mesh: sensor sample.

    3. My case is a battery powered sensor, so I have to make it as much power efficient as possible. The sample program doesnt seem to meet that goal. I tried commenting out each channel and it doesn't seem that affect the power consumption.  I tried using 'sensor_sample_fetch_chan (dev, SENSOR_CHAN_AMBIENT_TEMP) just to fetch temp channel, but still same. Any idea why?

    I'm not that familiar with the BME68x devices. What sample program are you referring to? The Sensors API in the Zephyr OS does have power management features
    There are options to set ultra low power using CONFIG_BME68X_IAQ_SAMPLE_RATE_ULTRA_LOW_POWER=y but I recommend looking through the BME68x driver documentation.

    4. I want to read/write registers of the sensor, but Sensor API doesn't seem to provide any interface. How can I do  this?

    I think you will need to look at the Sensor API 

    I hope this helps and provides some answers.

    Kind regards,
    Øyvind

  • Hi,

    Thanks for the reply.

    My SDK is 2.6.0.

    2. Unfortunately I cant find any driver like bme68x_irq under my 'drivers/sensor' folder. How can I install the bme68x driver code?

    3. I have managed to cut the power by turning off the heater for gas measurements. But I had to comment out the line 219 in bme680.c in 'drivers/sensor/bme680/'. The line is 

    __ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL)
    This seems like the 'chan' variable has to be SENSOR_CHAN_ALL or otherwise a kernel panic would occur. I want to measure just temp and humidity channel. What is the reason for this _ASSERT ?
    Cheers,
    Kaushalya
  • Hi,

    Need some help building the sample with CONFIG_BME68X_IAQ_SAMPLE_RATE_QUICK_ULTRA_LOW_POWER. I get the build errors saying

    C:/ncs/v2.6.0/nrf/drivers/sensor/bme68x_iaq/bme68x_iaq.c:35:32: error: 'BSEC_GAS_SAMPLE_RATE' undeclared here
    ..
    C:/ncs/v2.6.0/nrf/drivers/sensor/bme68x_iaq/bme68x_iaq.c:57:32: error: 'BSEC_SAMPLE_RATE' undeclared here
    ...
    C:/ncs/v2.6.0/nrf/drivers/sensor/bme68x_iaq/bme68x_iaq.c:463:35: error: 'BSEC_SAMPLE_PERIOD_S' undeclared

    If I use any other such as

    CONFIG_BME68X_IAQ_SAMPLE_RATE_ULTRA_LOW_POWER=y, it builds ok.
    I cant figure out what is the difference. 
    Please help.
    Cheers,
    Kaushalya

     

  • Hi Kaushalya, 

    my apologies for the late reply, for some reason my answer was not sent yesterday. I need to discuss internally in regards to the driver, and why it fails with QUICK_ULTRA_LOW_POWER and not ULTRA_LOW_POWER.

    I hope to have an answer by end of today or Monday.

    Kind regards,
    Øyvind

  • Hello again, 

    This is a bug and has been fixed in e.g. v2.8.0, but the problem is found in nrf\drivers\sensor\bme68x_iaq\CMakeLists.txt. In this file, ~ line 27, you can see that zephyr_library_compile_definitions_ifdef is pointing to BME68X_IAQ_SAMPLE_RATE_QUICK_ULTRA_LOW_POWER and not CONFIG_BME68X_IAQ_SAMPLE_RATE_QUICK_ULTRA_LOW_POWER

    If you replace the whole line with zephyr_library_compile_definitions_ifdef(BME68X_IAQ_SAMPLE_RATE_QUICK_ULTRA_LOW_POWER it should build as intended.

    Let me know how that works for you.


    KInd regards,
    Øyvind

  • Hi,

    I have infact done this modification earlier, but no luck. Strangely I built the project and SDK from scratch at home over the weekend and it was successful!! Only diff I did was I executed the

     

    west config manifest.group-filter +bsec
    west update

    within different folders. I cant exactly remember which is which, but does it matter you run the west update from within SDK folder or zephyr folder? The BME68X IAQ driver page does not indicate which folder you should be in before executing the west update. 

    Anyway I did the same today at my office project folder and got it compiled.

    Now I can get the BME68x driver reading from my project.

    I wanted to play around the sample timings as outlined in the 

    BSEC_SAMPLE_RATE=BSEC_SAMPLE_RATE_LP
    BSEC_GAS_SAMPLE_RATE=BSEC_SAMPLE_RATE_ULP
    BSEC_SAMPLE_PERIOD_S=3

    I found these timing values are defined in C:\ncs\v2.6.0\modules\lib\bsec\src\inc\bsec_datatypes.h. But when I changed the 'BSEC_SAMPLE_RATE_ULP' and 'BSEC_SAMPLE_RATE_LP' to different values (0.00167f and 0.017f) the driver seemed to stop sending any I2C comms to the BME68x. Any idea why?

    Also is there a way to modify these timings without modifying files in the SDK? Update the SDK and you loose all your settings.

    Cheers,

    Kaushalya

  • Hi,

    After further debugging, I can see with my modified timing, I get the ' BSEC_W_SC_CALL_TIMING_VIOLATION' error from 'bsec_sensor_control ()', which is invoked from 'bsec_thread_fn ()'.

    The comment of this this error code says 'Difference between actual and defined sampling intervals of bsec_sensor_control() greater than allowed'.

    I couldnt find the source of bsec_sensor_control ().  

    What are the limits of these timings? How can we change the timings to suit our application?

    Cheers,

    Kaushalya

Reply
  • Hi,

    After further debugging, I can see with my modified timing, I get the ' BSEC_W_SC_CALL_TIMING_VIOLATION' error from 'bsec_sensor_control ()', which is invoked from 'bsec_thread_fn ()'.

    The comment of this this error code says 'Difference between actual and defined sampling intervals of bsec_sensor_control() greater than allowed'.

    I couldnt find the source of bsec_sensor_control ().  

    What are the limits of these timings? How can we change the timings to suit our application?

    Cheers,

    Kaushalya

Children
  • Hello,

    kaushalyasat said:
    I can see with my modified timing,

    What modified timing did you perform? Please do not change timing in the drivers as this can cause issues with the root Bosch defined drivers. Our developers do not recommend changing these values due to the result that you got.

    kaushalyasat said:
    but does it matter you run the west update from within SDK folder or zephyr folder?

    Happy to see you were able to find the correct path and compile.

    Kind regards,
    Øyvind

  • Hi Øyvind,

    Thanks. 

    Please do not change timing in the drivers

    I need to relax the sample timing to support my power budget requirements. Does this mean I cant use any other timing than specified in the drivers?

    If it is possible, how can I change the sample timing?

    Happy to see you were able to find the correct path and compile.

    Thanks again. Is it within SDK folder or within Zephyr folder? It would be great if you can update the driver page to correctly instruct a newcomer which folder he/she should use to update west for BSEC drivers.

    Cheers,

    Kaushalya

  • Hey Kaushalya, 

    kaushalyasat said:

    I need to relax the sample timing to support my power budget requirements. Does this mean I cant use any other timing than specified in the drivers?

    If it is possible, how can I change the sample timing?


    I will need to discuss internally with the developers. 

    kaushalyasat said:
    Thanks again. Is it within SDK folder or within Zephyr folder?

    This is a driver found in sdk-nrf, so you should call west commands in the nrf folder. 

    kaushalyasat said:
    It would be great if you can update the driver page to correctly instruct a newcomer which folder he/she should use to update west for BSEC drivers.

    Yes, that is a very good point. I will notify internally! 

    Kind regards,
    Øyvind

Related