https://www.arduino.cc/en/Tutorial/MasterReader
master
#include <Wire.h> int bytes; uint8_t hbyte; uint8_t lbyte; void setup() { Wire.begin(); Serial.begin(9600); } void loop() { Wire.requestFrom(8, 6); if (!Wire.available()) { } hbyte = Wire.read(); lbyte = Wire.read(); Serial.print("hbyte: 0x"); Serial.print(hbyte,HEX); Serial.print(", "); Serial.print("lbyte: 0x"); Serial.println(lbyte,HEX); delay(500); }
slave
#include <Wire.h> void setup() { Wire.begin(8); Wire.onRequest(requestEvent); } void loop() { delay(100); } void requestEvent() { Wire.write(0x07); Wire.write(0x20); }