@kpuvvala
1. Make connection between NodeMCU and UNO-2 only as per Fig-1 of Post-3. Do not forget to install the I2C Bus pull-up resistors.
2. Upload the following sketch in NodeMCU.
#include <Wire.h>
void setup()
{
Wire.begin(D4, D3); //SDA=D4, SCL=D3
Serial.begin(9600); // start serial for output
//----------------------------------------------------------------
Wire.beginTransmission(9);
byte busStatus = Wire.endTransmission();
if(buStatus !=0)
{
Serial.print("UNO-2 is not found on I2C Bus.");
while(1); //wait for ever
}
Serial.println("UNO-2 is found on I2C Bus.");
}
void loop()
{
Wire.requestFrom(9, 1); // request bytes from slave device #8
byte y = Wire.read();
Serial.print("Reading 1-byte from Slave-2: ");
Serial.println(y, HEX);
//------------------------
delay(1000);
}
3. Upload the following sketch in UNO-2.
#include<Wire.h>
void setup()
{
Serial.begin(9600);
Wire.begin(9); ////UNO-2/Slave-2 Address
Wire.onRequest(sendEvent);
}
void loop()
{
}
void sendEvent()
{
Wire.write(0x27);
}
4. Check that the Serial Monitor of NodeMCU shows: 27 at 1-sec interval.
5. Now Connect UNO-1/Slave-1 and check that both slaves are operational.