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

Parents
  • 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

  • makoto.inoue said:
    When I try to change from i2c1 to i2c0 it starts showing me a red squiggly underline in nRF Connect for VS code stating it needs more parameters to be configured (ex. "pinctrl-0 is requried").

    This is because the i2c1 dts definition has pinctrl, while i2c0 has not yet been defined for the nRF5340DK cpuapp.
    Still, just keep on using i2c1 if that is the default, we should be able to make that one work.

    Maybe some of your pins are used by another resource, and this is why the i2c1 will not work?
    You can check this either by looking at build/zephyr/zephyr.dts or by using the VS Code visual dts editor:

  • Hi Sigurd,

    Thank you for the info.

    Last night I realized a critical error I made - nRF7002DK VDD is 1.8v (I assumed 3v). nRF52840DK is 3v. the SHT31-D board I am using requires at least 2.4v to turn on. This likely explains why nRF52840DK worked and nRF7002DK does not.

    I ordered a level shifter today, so whenever I receive it I will test it out and post the result here. 

  • Ah yes, I agree.
    This is likely the issue here.

    Good find!

  • Hi Sigurd,

    I can confirm that level shifter for the I2C solved the problem! I am getting the sensor readings now.

    The board overlay file ended up being:

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

    As a side note, I did have to try two different level shifters. Somehow PCA9306 based level shifter didn't work (maybe I got a dud one), but FXMA2102 based level shifter worked... 

    Anyway, thank you for your help!

    Best Regards,

    Makoto

  • Dear Nordic team, I think this ticket can be closed.

    I realized that I have few more tickets that probably should be closed (they have "Verified Answer" check).

    Do I ask it to be closed, or just let it go? Just curious what it should be...

Reply Children
Related