I need to work on twi compatible with smbus and I2C for NRF5340 DK

I need to interface my sensors by using twi. Here one of my sensor is smbus compatible. For I2C, I need to read acknowledge from sensor. So i need reference or samples to work on above requirements with NCS v1.5.0 for nrf5340dk

Thanks & regards

Navin

  • Check out this DevZone case: https://devzone.nordicsemi.com/f/nordic-q-a/63687/nrf52811-i2c-compatibilty

    It seems like the sensor should be compatible with I2C as long as you set the speed to 100kHz. Use the clock-frequency field in an i2c instance to configure the speed (see thingy91_nrf9160_common.dts and dt-bindings/i2c/i2c.h).

    Best regards,

    Simon

  • Hi Simon,

    Thank you very much, I have seen your ncs tutorial series that is very helpful. to get started to create an application nrf5340. I have understood part 1 and part 2.  I have got stuck at Part 3. It was a little difficult. give some implementation examples.

    I have tried to interface the sht20 sensor with nrf5340. My sensor output values are always constant. even I didn't connect my sensor it throws the same values.

    do you have any reference to interface external sensors other than given samples?

    It seems like the sensor should be compatible with I2C as long as you set the speed to 100kHz. Use the clock-frequency field in an i2c instance to configure the speed (see thingy91_nrf9160_common.dts and dt-bindings/i2c/i2c.h).

    I have tried the above. The same issue followed which I mentioned above.

    Thanks & Regards

    Navin

  • Mr.NCK said:

    I have tried to interface the sht20 sensor with nrf5340. My sensor output values are always constant. even I didn't connect my sensor it throws the same values.

    do you have any reference to interface external sensors other than given samples?

    It seems like you are creating the driver yourself. I would recommend you to start with the i2c_scanner example, and just see if you can communicate with the sensor. Then you can gradually, step-by-step, build on the example. Write to a register, read a register, read sensor values. Study the datasheet of the SHT20 closely.

    Do you have a logic analyzer? That's a very useful tool that allows you to see what's actually being sent.

    Best regards,

    Simon

  • Simon,

    Thank you for your response.

    I would recommend you to start with the i2c_scanner example,

    I have tried i2c_scanner_example.

    I can't able to read the device address. I have attached my output terminal below

    Thanks & Regards

    Navin

  • I made some modifications to the i2c_scanner sample:

    • Changed the name nrf5340pdk_nrf5340_cpuappns.overlay to nrf5340dk_nrf5340_cpuapp.overlay
    • Removed unecessary Kconfigs from the prj.conf
    • Swapped NRF_TWIM1_NS with NRF_TWIM1_S

    Could you test the updated sample with NCS v1.5.1 and the board nrf5340dk_nrf5340_cpuapp?

    i2c_scanner.zip

    Connect the sensor in the following manner:

    Sensor nRF5340 DK
    SDA P1.02 (34-32=2)
    SCL P0.04 (4)
    VIN VDD
    GND GND

    I tested the sample with a MAX4009 GY-49 and it worked fine. I got the following output:

    *** Booting Zephyr OS build v2.4.99-ncs2  ***                                                                                                                               v2.4.99-ncs2  ***
    The I2C scanner started
    Value of NRF_TWIM1_S->PSEL.SCL : 4
    Value of NRF_TWIM1_S->PSEL.SDA : 34
    Value of NRF_TWIM1_S->FREQUENCY: 26738688
    26738688 -> 100k
    0x4b FOUND

    Best regards,

    Simon

Related