I2c data encoding - Synchronise many arduinos

Ok :slight_smile: That is the complete master code :

#include <Wire.h>
void setup()
{
  Serial.begin(115200);
  TWBR = 400000L;
  Wire.begin(); 
}
void loop()
{
  Wire.beginTransmission(0x11);
  Wire.write(2);  
  Wire.endTransmission(); 
  delay(10);
  Wire.requestFrom(0x11, 1); 
  while(Wire.available())  
  { 
    char c = Wire.read(); //I tried both char and int types
    Serial.println(c);    
  }
  delay(500);
}

The slave code :

#include <Wire.h>
int readSerial ;
int readWire ;
#define SLAVE_ADDRESS 0x11
void setup(){
  TWBR = 400000L;
  Serial.begin(115200);
  pinMode(led, OUTPUT);
  Wire.begin(SLAVE_ADDRESS);
  Wire.onReceive(receiveData);
  Wire.onRequest(sendData);
 
}
void loop(){
}
void receiveData(int byteCount){
  while(Wire.available()) {
    readWire = Wire.read();
    if (readWire == 2){
      Serial.write(11);
      delay(0.05);
      if (Serial.available()){
        readSerial = Serial.read() ;
      }
    }
  }
}
void sendData(){
  int envoi = readSerial ;
  Wire.write(envoi);
}