Error using Wire.h library slave

I’m trying to send readings from an arduino-enabled IMU to a Sparkfun ESP 32 Thing microcontroller using the Wire.h library. I was using the Master Write/Slave Reader example just to see how it works. The Master Writer part for the IMU uploads without problems, but the Slave Reader for the microcontroller gets a compiling error:

"sketch\slaveReceiver.ino.cpp.o:(.literal._Z5setupv+0x18): undefined reference to `TwoWire::onReceive(void (*)(int))’

sketch\slaveReceiver.ino.cpp.o: In function `setup()’:

C:\Users\Taylor\Documents\slaveReceiver/slaveReceiver.ino:22: undefined reference to `TwoWire::onReceive(void (*)(int))’

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board SparkFun ESP32 Thing. "

Here’s the code I’m using for the receiving end…

#include <Wire.h>

void setup() {
  Wire.begin(8);                // join i2c bus with address #8
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600);           // start serial for output
}

void loop() {
  delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany) {
  while (1 < Wire.available()) { // loop through all but the last
    char c = Wire.read(); // receive byte as a character
    Serial.print(c);         // print the character
  }
  int x = Wire.read();    // receive byte as an integer
  Serial.println(x);         // print the integer
}

Any suggestions would be great.

Unfortunately, it looks like the ESP32 Wire library does not yet have an onReceive function, thus the error. Here’s the relevant bug report:

Unfortunately, I don’t have an answer for you as to how you can get around this. Perhaps someone else here on the forum will have a suggestion.