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

I need help for nrf5340 with I2c

Hi,

I am trying to learn the I2c with nrf5340 PDK. I need to interface Sht20 and Mlx90614 with nrf5340PDK. I need to know the procedures regards this on NRF Connect SDK

Thanks & Regards 

Navin

Parents Reply Children
  • Hey Markus,

    After the changes have done which you are said. I can't able to open my project actually.

    I have made some changes in my code and I got readings. But Readings from sensors are not varied. Can you help me regards?

    for clear understandings, I have tried to rewrite the Arduino library code to nrf  I2C

     /**********Arduino Code***********\
     
     uint16_t result;
    
        Wire.beginTransmission(eSHT2xAddress);
        Wire.write(command);
        delay(100);
        Wire.endTransmission();
    
        Wire.requestFrom(eSHT2xAddress, 3);
        uint32_t timeout = millis() + 300;       // Don't hang here for more than 300ms
        while (Wire.available() < 3) {
            if ((millis() - timeout) > 0) {
                return 0;
            }
        }
    
        //Store the result
        result = Wire.read() << 8;
        result += Wire.read();
        result &= ~0x0003;   // clear two low bits (status bits)
    
        //Clear the final byte from the buffer
        Wire.read();
    
        return result;

    I have tried to rewrite the above lines  to the below-mentioned code

    const struct device *i2c_dev;
    
      uint16_t result;
      uint16_t buff[10];
    
      i2c_dev = device_get_binding("I2C_1");
    
    
       i2c_write(i2c_dev,command,sizeof(command), eSHT2xAddress);
         k_msleep(300);
    
      result = i2c_read(i2c_dev, buff, sizeof(buff),  eSHT2xAddress)<< 8;
       result += i2c_read(i2c_dev, buff, sizeof(buff),  eSHT2xAddress);
        result &= ~0x0003;
    
        return result;
    
     

    Kindly, help me to get output.

    Thanks & Regards

    Navin

  • Hello, would you like to share an example of SHT20? Thank you very much

Related