My ESP8266 is I2C master while requesting data from sensors.
ESP8266 needs to get one byte from ESP32 also.
However, it looks like Wire.onRequest() is not implemented in ESP32 Arduino core and therefore ESP32 doesn't work as slave.
Is there a way I can go around this problem somehow?
I just need one byte back from ESP32 on ESP8266 request.
The I2C example sketch below returns compiling error in ESP32:
"ESP32_I2C_slave_test1.ino:16: undefined reference to `TwoWire::onRequest(void (*)())'"
#include <Wire.h>
void setup() {
Wire.begin(8); // join i2c bus with address #8
Wire.onRequest(requestEvent); // register event
}
void loop() {
delay(100);
}
// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent() {
Wire.write("hello "); // respond with message of 6 bytes as expected by master
}
As far as I know the ESP hardware doesn't support I2C slave mode. Theoretically you can emulate that in software (the ESP hardware should be fast enough for that) but that's a quite complicated task. It might help to tell us why you think you need that feature. There may be other solutions to your problem.