Arduino I2C: Wire.endTransmission() before or after Wire.requestFrom() ?
The correct order to call Wire
commands in Arduino is:
Wire.beginTransmission(MY_I2C_ADDR);
Wire.write(addr);
Wire.endTransmission();
Wire.requestFrom(MY_I2C_ADDR, 1); // Request one byte
delay(5); // Wait for data to be available
uint8_t value = Wire.read();
So you call Wire.endTransmission()
after Wire.write()
and call Wire.requestFrom()
directly after Wire.endTransmission()