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

I2c pin connections on nrf9160-DK

In the nrfConnect SDK I can see just one example for a I2C sensor - BH1749

I want to modify this for other I2C sensors.

However the README does not explain how to make the connections.  The nrf9160 datasheet does not seem to help much.

Can you suggest which pins to use and how to modify the configuration files.

For an initial test I'd like to use a BME280 in I2C mode.

Thx.

  • Hi, Paul!

    In chapter 1.2 of the nRF Connect SDK tutorial - Part 3, simon explains how the BME280 can be used with the nRF9160. I suggest trying out his approach. 

    Please reach out if you face any difficulities!

    Best regards,
    Carl Richard

  • Thx Carl

    I found ../ncs/zephyr/samples/sensor/bme280 in the SDK.

    Then added nrf9160dk_nrf9160ns.overlay in the boards folder:

    ```

    &i2c0 {
      bme280@77 {
        compatible = "bosch,bme280";
        reg = <0x77>;
        label = "BME280";
      };
    };

    ```

    When trying to build this I get 

    ```

    error: #error Your devicetree has no enabled nodes with compatible "bosch,bme280"

    ```

    I don't understand how to check that the following is valid for nrf9160dk

    ```

    BME280 Board
    SCL P0.31 
    SDA  P0.30 
    GND GND
    VIN VDD

    ```

    Regards.

    PS. Being that the DK has two Nordic chips on it, please note that I want to do this with the 9160 without using the nRF52840.  The DK board has pins labelled PO.30 and PO.31 but it's not clear how these are connected.

  • Hi again!

    First, you are correct that the DK has two chips on it, but as it is a nRF9160 development kit all GPIO are routed to the SiP. You can read more about available GPIO and the nRF52840's role on the board in the Hardware description.

    As shown in the tutorial I linked the SDA and SCL pins must be specified in the overlay aswell. Furthermore, I recommend using I2C1 as I2C0 can't coexist with UART0. UART0 is by default used for serial logging from the DK. When using the following nrf9160dk_nrf9160ns.overlay the sample built successfully for me:

    &i2c1 {
        compatible = "nordic,nrf-twim";
    	status = "okay";
    	sda-pin = < 30 >;
    	scl-pin = < 31 >;
        clock-frequency = <I2C_BITRATE_STANDARD>;  
    	
    	/* The I2C address could be one of two, here 0x76 is assumed */
    	bme280@76 {
    		compatible = "bosch,bme280";
    		reg = <0x76>;
    		label = "BME280";
    	};
    };
    
    &uart1 {
        status = "disabled";
    };


    I used the following prj.conf:
    CONFIG_SENSOR=y
    CONFIG_BME280=y
    CONFIG_I2C_1=y
    CONFIG_I2C=y


    Best regards,
    Carl Richard

  • Thx for the clarification Carl.

    I checked the two files and all is as above, however, I still get the same error.

    Your devicetree has no enabled nodes with compatible "bosch,bme280"

    I wonder if I have the .overlay file in the right place?

    ```

    ..ncs/zephyr/samples/sensor/bme280

      boards

        nrf9160dk_nrf9160ns.overlay

      build

      CMakeLists.txt

      Kconfig

      prj.conf

      src

        main.c

    ```

    BTW. I also checked the .yaml file and put nrf9160dk_nrf9160ns in the platform_allow field.

  • I see. How are you building the sample? When using SES the project must be reloaded before the changes apply. When using commandline tools the application should be built as "pristine".

    Best regards,
    Carl Richard

Related