Environment
- Board: Seeed Studio XIAO ESP32-C5 (x2)
- arduino-esp32 core: 3.3.10
- Arduino IDE: 2.3.10
- I2C pins: D4 (SDA), D5 (SCL) — set explicitly
- Pull-ups: 4.7k to 3V3 on both lines (rail confirmed at 3.3V)
- Shared GND, both boards powered by USB
- Bus speed: tried both 400 kHz and 100 kHz
Code: Select all
#include <Wire.h>
#define I2C_ADDR 0x11
uint8_t buf[46]; // the record the master reads
void onRequest() {
Wire.write(buf, sizeof(buf));
}
void onReceive(int) {
while (Wire.available()) Wire.read();
}
void setup() {
Serial.begin(115200);
for (int i = 0; i < 46; i++) buf[i] = i; // dummy payload
Wire.begin((uint8_t)I2C_ADDR, D4, D5, 100000); // slave at 0x11 on D4/D5
Wire.onRequest(onRequest);
Wire.onReceive(onReceive);
Wire.slaveWrite(buf, sizeof(buf)); // pre-load response buffer
Serial.println("slave ready");
}
void loop() { delay(500); }
Code: Select all
#include <Wire.h>
#define I2C_ADDR 0x11
void setup() {
Serial.begin(115200);
Wire.begin(D4, D5); // controller on D4/D5
Wire.setClock(100000);
Serial.println("master ready");
}
void loop() {
int got = Wire.requestFrom((int)I2C_ADDR, 46);
Serial.printf("requestFrom got %d bytes\n", got); // <-- always 0
while (Wire.available()) Serial.printf("%02X ", Wire.read());
Serial.println();
delay(1000);
}
Already ruled out
- Wiring — verified pin-by-pin against the silkscreen on two breadboards (D4=SDA, D5=SCL, GND shared, 3V3 feeding the pull-up rail).
- Pin mapping — pins set explicitly to D4/D5, not relying on defaults.
- SDA/SCL swap — tested reversed, no change.
- Pull-ups — 4.7k to 3V3, rail confirmed at 3.3V.
- Clock — tried 400 kHz and 100 kHz.
- slaveWrite pre-load — tried per the Espressif docs, no change.
- Slave is alive — it runs Wi-Fi scans and prints normally; it just never answers an I2C read.
- Has anyone run an ESP32-C5 as an I2C slave successfully? Which core version?
- Is C5 I2C-slave a known open issue in arduino-esp32 / ESP-IDF right now?
- Any workaround — different begin() signature, specific IDF version, HP_I2C vs LP_I2C peripheral, or a lower-level approach?