Hello Community,
I am new here and have a problem with the communication between the Arduino Uno and the NodeMcu via I2C.
The UN should read an Analogwet and send it to the NodeMCU, but it only ever receives the first value after booting. if the value changes then it does not change at the receiver or not correctly (see Serial monitor) COM4: Arduino COM5: NodeMCU
https://drive.google.com/file/d/1bOQiDjhvMgtqFcOpJsKrmxomSE_L_nGI/view?usp=drivesdk
https://drive.google.com/file/d/1bOQiDjhvMgtqFcOpJsKrmxomSE_L_nGI/view?usp=drivesdk
The code from the Arduino and the code from the NodeMcu is below ...
//Arduino code
#include <SoftwareSerial.h>
SoftwareSerial s(5,6);
const int analogInPin = A0;
int sensorValue = 0;
void setup() {
s.begin(9600);
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(analogInPin);
if(s.available()>0)
{
s.write(sensorValue);
}
Serial.println(sensorValue);
delay(2000);
}
//NodeMCU
#include <SoftwareSerial.h>
SoftwareSerial s(D6,D5);
int data;
void setup() {
s.begin(9600);
Serial.begin(9600);
}
void loop() {
s.write("s");
if (s.available()>0)
{
data=s.read();
Serial.println(data);
}
delay(2000);
}
Try the following codes for your Arduino (yours one with slight modification):
//Arduino code
#include <SoftwareSerial.h>
SoftwareSerial s(5,6);
const int analogInPin = A0;
int sensorValue = 0;
void setup() {
s.begin(9600);
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(analogInPin);
//if(s.available()>0)
//{
// s.write(sensorValue);
//}
s.print(sensorValue);
s.print('\n');
Serial.println(sensorValue);
delay(2000);
}
Would be glad to see the connection diagarm between Arduino and esp8266 over UART Port.
Please, change your title from I2C to UART.
Thanks for the Help i will try it
I wired it as in the bottom link
https://images.app.goo.gl/v9VaTQqfzV7BrvFj8
1. Pictorial view of UNO + ESP

Figure-1:
2. Your declarations are:
For UNO: s(5, 6); // DPin-5 = SRX and DPin-6 = STX
For ESP : s(D6, D5); // D6 = SRX, D5 = STX
3.
So, DPin-5 of UNO will be connected with D5 of ESP
So, DPin-6 of UNO will be connected with D6 of ESP
So. GND of UNO will be connected with GND of ESP
4. The connection that you have refereed is the following.

Figure-2:
5. In Fig-2, we observe --
DPin-5 of UNO will be connected with D5 of ESP //correct; it agrees with Step-3.
DPin-6 of UNO will be connected with D6 of ESP //correct; it agrees with Step-3.
GND of UNO is not connected with GND of ESP //wrong; it does not agrees with Step-3.

