I2C Read timeout too long
Posted: Fri Feb 18, 2022 2:23 pm
We are using ESP-IDF version 4.3.2. and we are using the I2C comunication with LM75 sensor. In some cases this sensor is disabled and a I2C timeout should occur. Since this is in the main loop and we need a fast execution, the I2C timeout should be the minimun posible. We are observing that the timeout the comunication is 1 second every time.
This is the code we are using for read LM75 sensor. As you can see we have set a maximum wait of 10 ms in the i2c_master_cmd_begin function, but we are observing 1 second timeouts.
Thanks in advance.
This is the code we are using for read LM75 sensor. As you can see we have set a maximum wait of 10 ms in the i2c_master_cmd_begin function, but we are observing 1 second timeouts.
Code: Select all
esp_err_t ret;
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (addr_lm75 << 1 | I2C_MASTER_WRITE), I2C_MASTER_ACK);
i2c_master_write_byte(cmd, reg_lm75, I2C_MASTER_ACK);
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (addr_lm75 << 1 | I2C_MASTER_READ), I2C_MASTER_ACK);
if (length_lm75 > 1)
{
i2c_master_read(cmd, val_lm75, length_lm75 - 1, I2C_MASTER_ACK);
}
i2c_master_read_byte(cmd, val_lm75 + length_lm75 - 1, I2C_MASTER_NACK);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(I2C_NUM_0, cmd, pdMS_TO_TICKS(10));
i2c_cmd_link_delete(cmd);
return ret;