I am experiencing an issue with the I2C device on the nRF5340(our custom board) where it is unable to read/write to the sensor, resulting in a return value of -5.(EIO)
Details:
- SDK Version: v2.6.1
- Custom Board : nrf5340-nrf7002
- Temperature sensor : SHT302x
Build Configuration in vs code: board = nrf7002dk-nrf5340-cpuapp-ns
- prj.conf:
CONFIG_I2C=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_PSA_WANT_ALG_HMAC=y
I2C project file
#include <zephyr/sys/printk.h> #include <stdio.h> #include <string.h> #include <zephyr/drivers/i2c.h> #include <zephyr/kernel.h> #define I2C_INST DT_NODELABEL(arduino_i2c) #define DEVICE_ADDRESS 0x44 #define DEVICE_ID_COMMAND_MSB 0x37 #define DEVICE_ID_COMMAND_LSB 0x80 const struct device *const i2c = DEVICE_DT_GET(I2C_INST); int main(void) { bool retValue = false; printk("Hello World! %s\n", CONFIG_BOARD); static const unsigned char string[] = "Hello world!"; int len = strlen((const unsigned char *) &string); if (!device_is_ready(i2c)) { printk("i2c is not ready!\n"); } else { printk("i2c is ready\n"); } uint8_t command[2] = {0}; command[0] = DEVICE_ID_COMMAND_MSB; command[1] = DEVICE_ID_COMMAND_LSB; uint8_t command2[2] = {0}; int transferedData = 0; transferedData = i2c_write_read(i2c, 0x44, &command, 2, &command2, 3); printk("transferedData %d\n", transferedData); return 0; }