How to configure two or more sensors (Having different Address) on same i2c bus in Zephyr RTOS - NRF connect SDK

Hi Everyone,

I am trying to configure multiple sensors on same I2C bus using Zephyr RTOS, but I am not able to find any reference for the same.

Can anyone please help me in Configuring two sensor on same i2c bus in Zephyr RTOS? I am able to interface single sensor on I2C port but how can we interface multiple sensors(4-5 sensors with different i2c address)on the same i2c bus in Zephyr RTOS – NRF connect SDK.

Thanks & Regards,

Pradeep

Parents
  • Here is a mock up example, inspired by the article Introduction to devicetree.

    Create a file named <board_variant>.overlay and add the code below to this file. Place the file in your project folder.

    Read more about overlay files in the getting started guide for nRF Connect SDK:

                    i2c0 {
                            compatible = "nordic,nrf-twim";
                            status = "okay";
                            label = "I2C_0";
                            sda-pin = <30>;
                            scl-pin = <31>;
                            clock-frequency = <I2C_BITRATE_FAST>;
    
                            apds9960@39 {
                                    compatible = "avago,apds9960";
                                    label = "APDS9960";
                                    reg = <0x39>;
                            };
                            ti_hdc@43 {
                                    compatible = "ti,hdc", "ti,hdc1010";
                                    label = "HDC1010";
                                    reg = <0x43>;
                            };
                            mma8652fc@1d {
                                    compatible = "nxp,fxos8700", "nxp,mma8652fc";
                                    label = "MMA8652FC";
                                    reg = <0x1d>;
                            };
                    };

    Here is another example:

    &i2c2 {
        compatible = "nordic,nrf-twim";
    	status = "okay";
    	sda-pin = < 30 >;
    	scl-pin = < 31 >;
        clock-frequency = <I2C_BITRATE_STANDARD>;  
    	
    
    	bme280@82 {
    		compatible = "bosch,bme280";
    		reg = <0x82>;
    		label = "BME280";
    	};
    	
    		bme280@76 {
    		compatible = "bosch,bme280";
    		reg = <0x76>;
    		label = "BME280";
    	};
    	
    };

    Please also consult this guide: TWI/I2C implementation with nRFx TWIS Driver.

    Would you be able to share your overlay file?

    Best regards,

    Håkon

  • Good Evening Helsing,

    Thanks you so much for your reply!

    Currently I working on it and i'll share the overlay file with you soon.

    Thanks & Regards,

    Pradeep

Reply Children
Related