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

Unable to Connect nRF5340DK with BMI270 Over I2C

I am attempting to get the BMI270 sample working on an nRF5340DK, using nRF Connect SDK v1.6.0, but all attempts at device_get_binding("BMI270"), device_get_binding(DT_LABEL(DT_INST(0, bosch_bmi270))), and similar return null.  I am using the following config and overlay files

#prj.conf

CONFIG_UART_CONSOLE=n
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y

CONFIG_I2C=y
CONFIG_SENSOR=y
CONFIG_BMI270=y

/* nrf5340dk_nrf5340_cpuapp.overlay - no shield */

&arduino_i2c {
	status = "okay";

	bmi270@68 {
		compatible = "bosch,bmi270";
		reg = <0x68>;
		label = "BMI270";
	};
};

On the hardware side I'm using a BMI270 breakout connecting SDA to P1.02 and SCL to P1.03.

I have also used a shield that sends SDA to P0.25 and SCL to P0.26, with the following overlay

/* nrf5340dk_nrf5340_cpuapp.overlay - with shield */

&i2c1 {
    sda-pin = <25>;
    scl-pin = <26>;
};

&arduino_i2c {
	status = "okay";

	bmi270@68 {
		compatible = "bosch,bmi270";
		reg = <0x68>;
		label = "BMI270";
	};
};

In all attempted cases

#include <zephyr.h>
#include <device.h>
#include <drivers/sensor.h>
#include <stdio.h>

void main(void)
{
	const struct device *dev;

	dev = device_get_binding("BMI270");

	if (dev == NULL) {
		printf("Could not get %s device\n",
		       DT_LABEL(DT_INST(0, bosch_bmi270)));
		return;
	}
	...
}

gives the output

00> *** Booting Zephyr OS build v2.6.0-rc1-ncs1  ***
00> Could not get BMI270 device

in J-Link RTT Viewer.

Any help would be greatly appreciated.

Parents Reply Children
  • Hello again!

    Thank you for the Zephyr.dts. It looks good to me, so the issue isn't there likely. Some more questions:
    - Which board are your targeting, nrf5340dk_nrf5340_cpuapp or nrf5340dk_nrf5340_cpuappns?
    - Are you able verify there is actually some activity on the I2C pins using a logic analyzer, oscilloscope or similar?
    - Have you verified that you are using the correct I2C address? I have a I2C Scanner sample that can be used for checking for I2C addresses on the bus. Some changes might be needed, including an overlay for your target board.

    There is production support for the nRF5340 in the current release of NCS/Zephyr, but you can consider using the nRF52840 if that's more fitting for your application. The two devices are very different and interchanging samples won't necessarily out-of-the box.

    Best regards,
    Carl Richard

Related