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 Sigurd,

    I have not gotten the i2c0 that builds yet (not with nrf7002dk_nrf5340_cpuapp board). 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"). It is not important to me whether I use i2c0 or i2c1, I'm just looking for a configuration that works.

    From what I can tell, GPIO output current levels are same for both nRF52840 and nRF5340. Since I can get the example working for nRF52840, I think that there is no need for extra GPIO setup for nRF5340.  

  • 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

Related