I want to know why Wire.onRequest
can not detect below massage and what I can do to detect it.(I am not able to change I2C massage)
I was able to read this part of the massage with wire.onReceive
:
But I can not read this massage at all, which is requesting:
#include <Wire.h>
byte val = 170;
int sendv;
char c;
byte dataArray[16];
void setup() {
Wire.begin(0x77); // join i2c bus with address #8
Wire.onReceive(receiveEvent); // register event
Wire.onRequest(requestEvent); // register event
Serial.begin(9600); // start serial for output
}
void loop() { }
void receiveEvent(int howMany) {
Serial.println(howMany);
if (howMany >= 2) {
for (int i = 0 ; i < howMany; i++) {
dataArray[i] = Wire.read();
Serial.println(dataArray[i], HEX);
}
} else {
c = Wire.read();
Serial.println(c, HEX);
}
}
void requestEvent() {
Serial.println("REqEVENT");
}
onRequest
callback you would write data to the I2C buffer, so that it can be send