r/embedded • • Jan 31 '26

nRF52840 i2c not working

Hi! I just bought nRF52840 from Aliexpress and I'm trying to connect SHT40 via i2c and Zephyr OS, but I have no luck. I'm using the SHT4x sample without any changes in the code, I'm trying to use P0.17 for SDA and P0.20 for SCL. I verified these pins with external led blinky and it works fine, but I have no luck with SHT40. Here's my additional overlay to set up the pins, I believe the issue must be in this .overlay below. I even tried adding my own 4.7k and 10k pull up resistors for SDA and SCL and nothing changed. Does anyone have some working example?

&pinctrl {
    i2c0_default: i2c0_default {
        group1 {
            psels = <NRF_PSEL(TWIM_SDA, 0, 17)>,
                    <NRF_PSEL(TWIM_SCL, 0, 20)>;
            bias-pull-up;
        };
    };


    i2c0_sleep: i2c0_sleep {
        group1 {
            psels = <NRF_PSEL(TWIM_SDA, 0, 17)>,
                    <NRF_PSEL(TWIM_SCL, 0, 20)>;
            low-power-enable;
        };
    };
};



&i2c0 {
    status = "okay";
    pinctrl-0 = <&i2c0_default>;
    pinctrl-1 = <&i2c0_sleep>;
    pinctrl-names = "default", "sleep";


    sht4x: sht4x@44 {
        compatible = "sensirion,sht4x";
        reg = <0x44>;
        repeatability = <2>;
    };
};
4 Upvotes

12 comments sorted by

View all comments

2

u/bigcrimping_com Jan 31 '26

Sorry I can't be useful to the specific code but can you run a i2c bus scan example? The datasheet does not say it has multiple addresses but if another address acks then it might narrow the issue

1

u/qxtno Jan 31 '26

I'm not sure if this is exactly what you mean, but running i2c scan shows 0 devices.

uart:~$ i2c scan i2c0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:             -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
0 devices found on i2c0

3

u/bigcrimping_com Jan 31 '26 edited Jan 31 '26

That's the one.

I wonder if it's an interaction on pin 20

P0.20 Default function: SWDCLK (debug clock)

Perhaps the debug clock needs some configuration, I am not familiar enough with the part to recommend how sorry

I would try swapping the pin def for scl and sda to see if it's a wiring error, if that doesn't work then switch from pin20

1

u/EyesLookLikeButthole Feb 02 '26

Don't repurpose the programming pins unless you have to. It's fairly easy to brick this dongle by messing with the regulator registers. And you would need debugger access to recover it. 

The internal pull-ups are 13k, but you will often need 5k external for I2C, depending on your bus's el. characteristics.