SHT31 readout on nRF5340 using the Zephyr Sample

Hi everyone,

I am trying to get the Zephyr SHT31 sample running on a nRF7002-DK (nrf5340), but I only get "Device SHT3XD is not ready".

I ran a debug session, and it is failing due to zephyr/kernel/device.c::z_device_is_ready funcition returning false.

somehow the dev->state->initialized = true, but dev->state->init_res = 5 (needs to be 0 for the function to return true).

My guess is that I need to fix my device overlay file - below is the device overlay file I am using:

&i2c1 {
	sht3xd@44 {
		compatible = "sensirion,sht3xd";
		reg = <0x44>;
		label = "SHT3XD";
	};
};

Thanks!

Makoto

  • Hi,

    Have you enabled I2C in prj.conf?

    Your driver should be enabled in the devicetree overlay with

    status = "okay";

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    Thank you for your help.

    Yes, I have enabled I2C in prj.conf. Below is my prj.conf:

    CONFIG_STDOUT_CONSOLE=y
    CONFIG_I2C=y
    CONFIG_SENSOR=y
    CONFIG_CBPRINTF_FP_SUPPORT=y

    I've tried with status = "okay"; added to the overlay file:

    &i2c1 {
    	sht3xd@44 {
    		compatible = "sensirion,sht3xd";
    		status = "okay";
    		reg = <0x44>;
    		label = "SHT3XD";
    	};
    };

    But I still get the same problem in device.c (line 103): dev->state->init_res = 5

    FYI the same hardware setup works (I get both temperature and humidity readouts) with nRF52840DK.

    Also I am using the code from here:

    https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/sensor/sht3xd/README.rst

    In the above documentation, I see an entry:

    "Depending on the baseboard used, the SDA and SCL lines require Pull-Up resistors."

    Would I need pull-up resistors when working with nRF7002DK board (nRF52840DK works with the same setup)?

    Thanks,

    Makoto

  • Hi,

    It is the i2c1 which needs to be enabled:

    &i2c1 {
    	status = "okay";
    	sht3xd@44 {
    		compatible = "sensirion,sht3xd";
    		reg = <0x44>;
    		label = "SHT3XD";
    	};
    };

    By the way, is there a reason to why you use i2c1 instead of i2c0?

    makoto.inoue said:
    Would I need pull-up resistors when working with nRF7002DK board (nRF52840DK works with the same setup)?

    As long as the nRF7002DK does not have pull-ups on the Development Kit on the pins you use, you need those, yes.
    And I do not believe it has. To verify this, you can check its hardware files.

  • Hi Sigurd,

    I've tried the suggested edits/configuration, but it still does not work.

    The reason I'm using i2c1 instead of i2c0 is because the Arduino pin layout for SCL and SDA are mapped to:

    SCL -> P1.03

    SDA-> P1.02

    of the nRF5340. I have wired my SHT31-D board's SCL and SDA to those pins. Hence I thought it needed to use port1 instead of port 0, so i2c1 instead of i2c0. Maybe this is configurable/flexible and I don't have to insist on using i2c1.

    Does an i2c current drive level differ on nRF5340 than nRF52840? I remember in when interfacing a particular kind of a touch LCD with nRF52840, I needed to increase the SPI's current drive level (needed an extra GPIO configuration). Maybe something similar is required for nRF5340 when interfacing older i2c devices...?

    Also note that I checked the SHT31-D board, and it has pull-up resisters for both SCL and SDA, so that is taken care.

  • Hi,

    The nRF5340 is not pin-locked. You can use any pins you want for I2C, but see pin assignements for some notes.
    To change pins used for either i2c0 or i2c1, see Pin Control.

    The i2c0 and i2c1 both should work though. But if it builds fine for i2c0 for you, maybe no need to figure out why i2c1 does not work?

    makoto.inoue said:
    Does an i2c current drive level differ on nRF5340 than nRF52840? I remember in when interfacing a particular kind of a touch LCD with nRF52840, I needed to increase the SPI's current drive level (needed an extra GPIO configuration). Maybe something similar is required for nRF5340 when interfacing older i2c devices...?

    For drive current, see GPIO electrical specification.

Related