PlatformIO Community

nRF52840 I2C not working

I am trying to communicate with a BME680 over the I2C on a nRF52840. I am using PlatformIO (Core v4.3.4 and Home v3.2.3), VSCode v1.489.2, MacOS 10.15.6, nordicnf52 v4.4.0, and Zephyr v2.3.0.

I am trying to move to Zephyr with a known good custom PCB using the nRF52840. The code I am hoping to refactor using Zephyr reads the BME680 without error, so I know the circuit is correct.

I have created the custom board files and most things seem to work so far. However, I am having difficulty with my BME680. However, when I scope out the SCK line while attempting to communicate with the BME680 it just stays pulled high and doesn’t toggle with the clock signal.

Following is the entry for the BME680 in the device tree.

&i2c0 {
	compatible = "nordic,nrf-twi";
	status = "okay";
	clock-frequency = <I2C_BITRATE_STANDARD>;
	sda-pin = <8>;
	scl-pin = <41>;
	bme680@76 {
		compatible = "bosch,bme680";
		label = "BME680";
		reg = <0x76>;
	};
};

Following are the other relevant settings.

From prj.conf

CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_SENSOR=y
CONFIG_BME680=y

From Kconfig.defconfig

config I2C_NRFX
    bool "nRF TWI nrfx drivers"
    default y
    depends on SOC_FAMILY_NRF && I2C
    help
      Enable support for nrfx TWI drivers for nRF MCU series.
config BME680
    bool "BME680 sensor"
    depends on I2C && SENSOR
    help
      Enable driver for BME680 I2C-based based temperature, pressure, humidity and gas sensor.

From main.c

#include <device.h>
#include <devicetree.h>
#include <sys/printk.h>
#include <sys/util.h>
#include <zephyr.h>
#include <zephyr/types.h>
#include <drivers/sensor.h>
#define BME680 DT_INST(0, bosch_bme680)
#if DT_NODE_HAS_STATUS(BME680, okay)
#define BME680_LABEL DT_LABEL(BME680)
#else
#error "Your device tree has no enabled nodes with compatible "bosch,bme680""
#define BME680_LABEL "<none>"
#endif
struct device *Bme680Device = device_get_binding(BME680_LABEL);
if (Bme680Device == NULL) {
        printk("No device \"%s\" found; did initialization fail?\n", BME680_LABEL);
}