This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can't connect to BME280 sensor - i2c_nrfx_twim: Error 195952641 occurred for message 0

Hi,

I am trying to run the Zephyr BME280 sensor sample application (using nRF9160 DK) in NCS1.3.1, but get the below error:

SPM: NS image at 0xc000
SPM: NS MSP at 0x20020b50
SPM: NS reset vector at 0xdafd
SPM: prepare to jump to Non-Secure image.
[00:00:00.000,000] <dbg> BME280.bme280_init: initializing BME280
[00:00:00.000,091] <err> i2c_nrfx_twim: Error 195952641 occurred for message 0
[00:00:00.000,122] <dbg> BME280.bme280_chip_init: ID read failed: -5
[00:00:00.000,122] <dbg> BME280.bme280_init: BME280 failed
*** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
No device "BME280" found; did initialization fail?

My prj.conf is as follows:

CONFIG_SENSOR=y
CONFIG_BME280=y
CONFIG_I2C=y
CONFIG_I2C_1=y

And board overlay nrf9160dk_nrf9160ns.overlay is as follows:

&i2c1 {
  compatible = "nordic,nrf-twim";
	status = "okay";
	sda-pin = <30>;
	scl-pin = <31>;
  clock-frequency = <I2C_BITRATE_FAST>;

	bme280@77 {
		compatible = "bosch,bme280";
		reg = <0x77>;
		label = "BME280";
	};
};

&uart1 {
    status = "disabled";
};

I power the sensor using the DK's VDD.

I am however able to get things working with the exact same configuration when I deploy the sample to the nRF5340 PDK, replacing the overlay filename with nrf5340pdk_nrf5340_cpuapp.overlay.

Could someone kindly help? I cannot figure why I can't get the sample to work on the nRF9160 DK.

Parents Reply
  • Hi Martin,

    It turns out that removing the following

    &uart1 {
        status = "disabled";
    };

    resulted in the compilation failing with a helpful message:

    ./ncs/zephyr/include/toolchain/gcc.h:62:36: error: static assertion failed: "Only one of the following peripherals can be enabled: SPI1, SPIM1, SPIS1, TWI1, TWIM1, TWIS1, UARTE1. Check nodes with status \"okay\" in zephyr.dts."

    so I tried &i2c2 and everything worked as expected. Could this be a subtle bug in the processing of the overlay stack files, or am I missing something?

    Ta.

Children
Related