ENS210 sensor not getting ready during initialization on custom nRF52832 board

The ENS210 temperature and humidity sensor connected to an nRF52832 over the I2C interface is not getting ready during initialization. During boot, the ENS210 driver reports the following errors:

<err> ENS210: Failed to read SYS_STATE
<err> ENS210: Sensor is not in active state
<err> EN: ENS210 not ready

The driver fails while attempting to read the SYS_STAT register, returning an -EIO error.

Environment:

  • SoC: nRF52832

  • SDK: nRF Connect SDK v3.2.1

  • Sensor: ENS210

  • Interface: I2C

  • I2C Address: 0x43

  • Board: Custom board

Configuration

boards/board_name_defconfig

CONFIG_ENS210=y
CONFIG_SENSOR=y
CONFIG_SENSOR_LOG_LEVEL_DBG=y
CONFIG_I2C_LOG_LEVEL_DBG=y

sysbuild/mcuboot/boards/board_name.conf

CONFIG_ENS210=n

Device Tree

/ {
    vddEnable {
        compatible = "gpio-leds";
        vdd: vdd {
            gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>;
        };
    };
        aliases {
            vddenable = &vdd;
    };

};

&i2c1 {
    compatible = "nordic,nrf-twim";
    status = "okay";
    pinctrl-0 = <&i2c1_default>;
    pinctrl-1 = <&i2c1_sleep>;
    pinctrl-names = "default", "sleep";
    clock-frequency = <I2C_BITRATE_STANDARD>;

    ens210: ens210@43 {
        compatible = "ams,ens210";
        reg = <0x43>;
    };
};

Hardware Details

GPIO P0.31 controls an AP2280 load switch which connects the battery 3.3 V rail to the sensor VDD.
The I2C lines have external pull-up resistors.

Application Code

const struct device *ens210Sensor = DEVICE_DT_GET(DT_NODELABEL(ens210));

#define VDD_POWER    DT_ALIAS(vddenable)

 

int EN_powerInit(void)
{
    const struct gpio_dt_spec power = GPIO_DT_SPEC_GET(VDD_POWER, gpios);

    if (!device_is_ready(power.port)) {
        return -ENODEV;
    }

    gpio_pin_configure_dt(&power, GPIO_OUTPUT_ACTIVE);
    gpio_pin_set_dt(&power, 1);

    return 0;
}

void EN_FetchEns210Data(void)
{
    struct sensor_value temp, hum;

    sensor_sample_fetch(ens210Sensor);
    sensor_channel_get(ens210Sensor, SENSOR_CHAN_AMBIENT_TEMP, &temp);
    sensor_channel_get(ens210Sensor, SENSOR_CHAN_HUMIDITY, &hum);

    LOG_INF("Temp: %d.%06d C", temp.val1, temp.val2);
    LOG_INF("Hum: %d.%06d %%", hum.val1, hum.val2);
}

void main()
{
    EN_powerInit();
    EN_FetchEns210Data();
}

Expected Behavior

The ENS210 should enter the active state during initialization and allow temperature and humidity readings through the Zephyr sensor API.

Actual Behavior

The driver fails during initialization with -EIO while reading the SYS_STAT register, and the sensor is reported as not ready.

Parents Reply Children
Related