Slave receiver implementation


#1

Hello,
I am currently working with some Nano v2. The system basically send some data over bluetooth with a nano and another one is receiving. After that step I need to send this data to a main controller, a Red Bear Duo. I wanna send this data as quick as possible, maintaining a low power consumption. Thus I decided to go for I2C communication. Using the nano as master everything works fine, however, I need the Duo to be the master and it appears that the nano does not implement a slave mode for I2C.

void setup() {
  Wire.begin(0x08);                // 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
}

This is the code I am using for Duo as slave. Compiling it for the nano gives error on begin(int) and onReceive, that are not implemented.
Thank you.