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

I2C or SPI bridge between nrf9160 and nrf52840 (Thingy91)

Hello

I am developing a prototype with the Thingy 91 that allows to have the default log in the UART0 <-> USB and collect the data of a sensor through the P6 expansion port (nrf52 SPARE) through the UART1 of the nrf52840.
I need a bridge to share the sensor data between the nrf52840 and nrf9160 but I run into the problem that the two available UART instances are already busy. My question is if it is possible to bridge via I2C or SPI on the shared MCU_IF pins. For the nrf52840 code I am relying on the usb_uart_bridge example.

Thx!

Parents Reply
  • Following the example of zephry's BME280 sensor I get a compilation error: zephyr No SOURCES given to target: drivers__i2c

    I have also tried to communicate with the i2c driver of nrf (twi) but I get compilation errors like: error: 'DT_NORDIC_NRF_TWI_I2C_0_CLOCK_FREQUENCY' undeclared

    The nrf52840_pca20035.dts file:

    &i2c0 {
    	status = "okay";
    	compatible = "nordic,nrf-twim";
    	sda-pin = <25>;
    	scl-pin = <22>;
    	clock-frequency = <I2C_BITRATE_STANDARD>; 
    };

    The prj.conf file:

    CONFIG_I2C=y
    #CONFIG_SENSOR=y
    CONFIG_I2C_NRFX=y
    CONFIG_I2C_0=y
    CONFIG_I2C_0_NRF_TWI=y
    CONFIG_I2C_INIT_PRIORITY=60

Children
  • Have you configured correct address for the sensor? In the zephyr\samples\sensor\bme280\boards\nrf52840dk_nrf52840.overlay

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

    You must edit reg to correct i2c address. For my part it was 76 which was the correct address. 

    Kind regards,

    Øyvind

  • Thanks for the info!

    Only that my goal is to enable an I2C for the nrf52840_pca20035 board, not the nrf52840dk_nrf52840

  • My apologies for not being clear. 

    You can copy nrf52840dk_nrf52840.overlay to your project folder and rename to nrf52840_pca20035.overlay Depending on what NCS version you are on, make sure to use correct board name. From NCS v1.3.0 the board names of Thingy:91 were changed to: thingy91_nrf9160 and thingy91_nrf52840. What version of NCS are you working on?

    You can also copy the content of nrf52840dk_nrf52840.overlay and add to your nrf52840_pca20035.dts. The former will concatenate and add/overwrite settings to &i2c0, adding the bme280 as a child node to your &i2c0, providing a zephyr.dts that will look similar to:

    &i2c0 {
    	status = "okay";
    	compatible = "nordic,nrf-twim";
    	sda-pin = <25>;
    	scl-pin = <22>;
    	clock-frequency = <I2C_BITRATE_STANDARD>; 
    	bme280@77 {
    		compatible = "bosch,bme280";
    		reg = <0x77>;
    		label = "BME280";
    	};
    };

Related