i2c communication between arduino uno and nodemcu

Hi friend,
Im new one to forum, please guide if im wrong.

Im using nodemcu & arduino uno board for my project, i need to send a data from nodemcu to arduino uno depending that data arduino needs to send another data.

is it possible to use i2c as 2way communication between nodemcu & arduino.

i used Wire.requestFrom(,); , but it is not getting data.
im not getting any proper examples.

please help out, once again saying Im new to this stuff .

Thank you

is it possible to use i2c as 2way communication between nodemcu & arduino.

Not really. I2C is a bus with a strict master/slave hierarchy. So the master is asking the slave for data and the slave responds to this request but the slave is not able to send something to the master without the read request from the master.

i used Wire.requestFrom(,); , but it is not getting data.
im not getting any proper examples.

How did you connect it? The UNO runs on 5V, the ESP on 3.3V. A direct connection may damage the ESP.

The information/code of this link could be helpful for you.

Actually its pretty possible
(Can let back and forth communication)
code for nodemcu:

#include <Wire.h>

void setup() {
Serial.begin(9600); /* begin serial for debug /
Wire.begin(D1, D2); /
join i2c bus with SDA=D1 and SCL=D2 of NodeMCU */
}

void loop() {
Wire.beginTransmission(8); /* begin with device address 8 /
Wire.write(“Hello Arduino”); /
sends hello string /
Wire.endTransmission(); /
stop transmitting */

Wire.requestFrom(8, 13); /* request & read data of size 13 from slave */
while(Wire.available()){
char c = Wire.read();
Serial.print(c);
}
Serial.println();
delay(1000);
}

Arduino Uno:

#include <Wire.h>

void setup() {
Wire.begin(8); /* join i2c bus with address 8 /
Wire.onReceive(receiveEvent); /
register receive event /
Wire.onRequest(requestEvent); /
register request event /
Serial.begin(9600); /
start serial for debug */
}

void loop() {
delay(100);
}

// function that executes whenever data is received from master
void receiveEvent(int howMany) {
while (0 <Wire.available()) {
char c = Wire.read(); /* receive byte as a character /
Serial.print(c); /
print the character /
}
Serial.println(); /
to newline */
}

// function that executes whenever data is requested from master
void requestEvent() {
Wire.write(“Hello NodeMCU”); /*send string on request */
}

arduino pin A4 to NodeMCU D1
arduino pin A5 to NodeMCU D2
ground of arduino to NodeMCU ground