This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SHT31 readout on nRF9160 using the Zephyr Sample

Dear Devzone Community,

when trying to get the Zephyr SHT31 Sample running, I stumbled across an error which I was not able to resolve.

I did the following:

  • Add nrf9160dk_nrf9160ns.overlay in zephyr\samples\sensor\sht3xd\boards with following content:
    &i2c0 {
    	sht3xd@44 {
    		compatible = "sensirion,sht3xd";
    		reg = <0x44>;
    		label = "SHT3XD";
    	};
    };
  • Open Project 'sht3xd' with board 'nrf9160dk_nrf9160ns' in SES
  • Leave configuration as is
  • Build solution

The output window then shows the error:

'DT_N_S_soc_S_peripheral_40000000_S_i2c_8000_S_sht3xd_44_BUS_P_label' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_40000000_S_i2c_8000_S_sht3xd_44_P_label'?

Which directs to the file 'devicetree_unfixed.h'. The error is shown to occur at this line:

#define DT_N_INST_0_sensirion_sht3xd DT_N_S_soc_S_peripheral_40000000_S_i2c_8000_S_sht3xd_44

Did someone have a similar experience?

Thank you and kind regards

Parents
  • Try to add the following content to nrf9160dk_nrf9160ns.overlay, that should compile fine

    &i2c2 { /* SDA P0.26, SCL P0.27, ALERT P1.10 */
        status = "okay";
        compatible = "nordic,nrf-twim";
        sda-pin = < 30 >;
        scl-pin = < 31 >;
        sht3xd@44 {
    		compatible = "sensirion,sht3xd";
    		reg = <0x44>;
    		label = "SHT3XD";
    	};
    };


    Explanation:

    The reason it failed initially was because you hadn't enabled the i2c0 node (status="okay"), in addition you need to add the required fields compatible, sda-pin and scl-pin. However, since both uart0 and uart1 is enabled in ncs\v1.4.0\zephyr\boards\arm\nrf9160dk_nrf9160\nrf9160dk_nrf9160_common.dts you can't use i2c0 or i2c1, since they occupy the same memory. Instance i2c2 should be fine to use, however for that instance, all the fields are already set, so it's not really necessary to set them again in the overlay file.

    Best regards,

    Simon

Reply
  • Try to add the following content to nrf9160dk_nrf9160ns.overlay, that should compile fine

    &i2c2 { /* SDA P0.26, SCL P0.27, ALERT P1.10 */
        status = "okay";
        compatible = "nordic,nrf-twim";
        sda-pin = < 30 >;
        scl-pin = < 31 >;
        sht3xd@44 {
    		compatible = "sensirion,sht3xd";
    		reg = <0x44>;
    		label = "SHT3XD";
    	};
    };


    Explanation:

    The reason it failed initially was because you hadn't enabled the i2c0 node (status="okay"), in addition you need to add the required fields compatible, sda-pin and scl-pin. However, since both uart0 and uart1 is enabled in ncs\v1.4.0\zephyr\boards\arm\nrf9160dk_nrf9160\nrf9160dk_nrf9160_common.dts you can't use i2c0 or i2c1, since they occupy the same memory. Instance i2c2 should be fine to use, however for that instance, all the fields are already set, so it's not really necessary to set them again in the overlay file.

    Best regards,

    Simon

Children
Related