Trouble reading I2C device
Posted: Thu Oct 13, 2022 1:17 pm
PLATFORM: Espressif 32 (5.2.0) > OLIMEX ESP32-EVB
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog)
framework-espidf @ 3.40402.0 (4.4.2)
I'm struggling to get I2C working properly when reading. I've got an LCD working fine over I2c via a PCF8574 board so I know the wiring is good. I'm also trying to read data from a custom device (Arduino Uno, addr 10) & the ESP32 will not run the clock.
This scope image shows SCL (Blue) and SDA (Red). After the device is addressed, the ESP master should run the clock and read out the data but it does not, instead it times out.

This scope image below shows a second Arduino Uno acting as master instead of the ESP32 (i.e. ESP32 removed and replaced with Uno), sending the same request and receiving the expected 5 byte response. For some reason, the ESP32 (i2c_master_cmd_begin) times out whereas the Uno works even when the signals are very rounded!

Any ideas?
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog)
framework-espidf @ 3.40402.0 (4.4.2)
I'm struggling to get I2C working properly when reading. I've got an LCD working fine over I2c via a PCF8574 board so I know the wiring is good. I'm also trying to read data from a custom device (Arduino Uno, addr 10) & the ESP32 will not run the clock.
This scope image shows SCL (Blue) and SDA (Red). After the device is addressed, the ESP master should run the clock and read out the data but it does not, instead it times out.
Code: Select all
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
err = i2c_master_start(cmd);
i2c_master_write_byte(cmd, (RFID_ADDR << 1) | I2C_MASTER_READ, ACK_CHECK_EN);
if (numBytes > 1)
{
i2c_master_read(cmd, data, numBytes - 1, ACK_VAL);
}
i2c_master_read_byte(cmd, data + numBytes - 1, NACK_VAL);
err = i2c_master_stop(cmd);
err = i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000 / portTICK_PERIOD_MS);
i2c_cmd_link_delete(cmd);
ok = err == ESP_OK;
This scope image below shows a second Arduino Uno acting as master instead of the ESP32 (i.e. ESP32 removed and replaced with Uno), sending the same request and receiving the expected 5 byte response. For some reason, the ESP32 (i2c_master_cmd_begin) times out whereas the Uno works even when the signals are very rounded!
Any ideas?