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
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
Thanks a lot for the feedback, Navin!
Could you please add:
CONFIG_CBPRINTF_FP_SUPPORT=y
to prj.conf and replace printf with printk?
Does that make any difference?
Regards,
Markus
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 Navin,
So I guess that:
i2c_write(i2c_dev,command,sizeof(command), eSHT2xAddress); k_msleep(300);
requests data from the sensor? What is the command you are writing to this function? Could you please check the return value of its call?
My assumption at the moment is that the buffer is not updated with new values.
Regards,
Markus
Hi Markus,
Command = Register address;
its returns some value but not accurate
can you please tell me how to rewrite the below section for nrf?
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; }
this same issue follows for mlx90641 also.
Thanks & Regards
Navin
Hello Navin,
with return value i meant the value that the function call returns and not the arguments of the function.
Does it return 0 or -EIO?
Regards,
Markus