Fix ESP32 “[E][Wire.cpp] requestFrom(): i2cRead returned Error 263”
Error 263 is an I2C timeout (ESP_ERR_TIMEOUT): the device didn’t answer or held the clock too long. Check wiring and pull-ups, slow the bus, raise the timeout.
Community draft — report a mistake
What you see
Reading sensor...
[ 12043][E][Wire.cpp:499] requestFrom(): i2cRead returned Error 263
[ 12095][E][Wire.cpp:499] requestFrom(): i2cRead returned Error 263
Temperature: nan CReading sensor... [ 12043][E][Wire.cpp:499] requestFrom(): i2cRead returned Error 263 [ 12095][E][Wire.cpp:499] requestFrom(): i2cRead returned Error 263 Temperature: nan C
These lines come from the ESP32 core’s Wire library, logged at error level. They mean an I2C read (or write) didn’t complete before the timeout. The sensor library usually carries on and returns nan or 0, so the log line is the real clue.
void setup() {
Wire.begin(21, 22);
Wire.setClock(100000); // 100 kHz
Wire.setTimeOut(200); // ms, for sensors that stretch the clock
}Quick fix — try in order
- 1
Scan the bus
Run the I2C scanner below. If the device is missing or appears only sometimes, fix wiring before touching the code.
- 2
Check pull-ups and wire length
SDA and SCL each need a pull-up to 3.3 V (4.7 kΩ typical; most breakouts include them). Long jumper wires (>30 cm) need stronger pull-ups or a lower speed.
- 3
Slow the bus down
Wire.begin(21, 22); Wire.setClock(100000);. Some sensors don’t cope with 400 kHz. - 4
Raise the timeout for clock-stretching sensors
SHT2x/HTU21D, CCS811, BNO055 and MLX90614 hold SCL low while measuring.
Wire.setTimeOut(200);(milliseconds) afterWire.begin()gives them time. - 5
Power-cycle a stuck device
A sensor that was reset mid-transfer can hold SDA low until it loses power. Unplug the 3.3 V wire for a second.
Diagnostic sketch
// I2C scanner — lists every device address that answers on the bus.
// ESP32 DevKit V1: SDA = GPIO21, SCL = GPIO22. Uno/Nano: SDA = A4, SCL = A5.
#include <Wire.h>
void setup() {
Serial.begin(115200);
while (!Serial) {}
#if defined(ARDUINO_ARCH_ESP32)
Wire.begin(21, 22); // SDA, SCL
#else
Wire.begin();
#endif
Serial.print("I2C scanner on SDA=");
Serial.print(SDA);
Serial.print(" SCL=");
Serial.println(SCL);
}
void loop() {
Serial.println("Scanning...");
uint8_t found = 0;
// 0x08..0x77 are the usable 7-bit addresses; the rest are reserved.
for (uint8_t addr = 0x08; addr <= 0x77; addr++) {
Wire.beginTransmission(addr);
uint8_t err = Wire.endTransmission();
if (err == 0) {
Serial.print("Found device at 0x");
if (addr < 0x10) Serial.print('0');
Serial.println(addr, HEX);
found++;
} else if (err == 4) {
Serial.print("Unknown error at 0x");
Serial.println(addr, HEX);
}
}
if (found == 0) {
Serial.println("No I2C devices found");
Serial.println("Check: SDA/SCL swapped? Module powered? Pull-ups present?");
} else {
Serial.print(found);
Serial.println(" device(s) found");
}
Serial.println();
delay(5000);
}// I2C scanner — lists every device address that answers on the bus.
// ESP32 DevKit V1: SDA = GPIO21, SCL = GPIO22. Uno/Nano: SDA = A4, SCL = A5.
#include <Wire.h>
void setup() {
Serial.begin(115200);
while (!Serial) {}
#if defined(ARDUINO_ARCH_ESP32)
Wire.begin(21, 22); // SDA, SCL
#else
Wire.begin();
#endif
Serial.print("I2C scanner on SDA=");
Serial.print(SDA);
Serial.print(" SCL=");
Serial.println(SCL);
}
void loop() {
Serial.println("Scanning...");
uint8_t found = 0;
// 0x08..0x77 are the usable 7-bit addresses; the rest are reserved.
for (uint8_t addr = 0x08; addr <= 0x77; addr++) {
Wire.beginTransmission(addr);
uint8_t err = Wire.endTransmission();
if (err == 0) {
Serial.print("Found device at 0x");
if (addr < 0x10) Serial.print('0');
Serial.println(addr, HEX);
found++;
} else if (err == 4) {
Serial.print("Unknown error at 0x");
Serial.println(addr, HEX);
}
}
if (found == 0) {
Serial.println("No I2C devices found");
Serial.println("Check: SDA/SCL swapped? Module powered? Pull-ups present?");
} else {
Serial.print(found);
Serial.println(" device(s) found");
}
Serial.println();
delay(5000);
}Why it happens
What is 263?
0x107 = ESP_ERR_TIMEOUT in ESP-IDF. The ESP32 waited for the I2C transaction to finish and gave up. Other values: -1 / 259 (ESP_FAIL / invalid state) usually mean a NACK — no device at that address.
endTransmission() returned Error 263
The write side of the same problem — same checks.
5 V module on a 3.3 V ESP32
A 5 V-powered module with its own pull-ups to 5 V can lock up the ESP32’s I2C pins. Use a level shifter, or power the module from 3.3 V if allowed.
Board-specific notes
ESP32: Default pins SDA 21 / SCL 22. The exact log line number (Wire.cpp:499) changes between core versions — the error number is what matters.
ESP32-C3: No fixed default I2C pins on many C3 boards — call Wire.begin(SDA, SCL) with your pins. See C3 SuperMini pinout.
Related: Nothing answers at all: I2C device not found.
Did this fix it?
Thanks — that helps us keep this page right.