Serial communication between Uno and ESP8266

I use this kind of communication in several projects. But only UNO sending data to the ESP8266. Never a single issue. I have never had a need to do the opposite. Now, while using the same code I can’t get the data from the ESP8266 to the UNO.

First to show you my INO files. This is sender:

#include <SoftwareSerial.h>
#include <ArduinoJson.h>
SoftwareSerial s(5,6);
void setup() {
  Serial.begin(9600);
  s.begin(115200);
}
void loop() {
 StaticJsonBuffer<1000> jsonBuffer;
 Serial.println("1");
 JsonObject& root = jsonBuffer.createObject();
 Serial.println("2");
  root["data1"] = 100;
  root["data2"] = 200;
  Serial.println("3");
if(s.available()>0){
 root.printTo(s);
 Serial.println("go");
}
}

This sketch is on UNO (could be MEGA too). It sends packets of data through JSON and with Software Serial. Later about that.

This is receiver INO and it is on ESP8266 (NodeMCU, D1 Mini, etc):

#include <SoftwareSerial.h>
SoftwareSerial s(D6,D5);
#include <ArduinoJson.h>
 
void setup() {
  Serial.begin(9600);
  s.begin(115200);
  while (!Serial) continue;
 
}
 
void loop() {
 StaticJsonBuffer<1000> jsonBuffer;
  JsonObject& root = jsonBuffer.parseObject(s);
  if (root == JsonObject::invalid())
    return;
  Serial.print("Data 1 ");
  int data1=root["data1"];
  Serial.println(data1);
  int data2=root["data2"];
  Serial.println(data2); 
}

This sketch receives the data through Software Serial and prints it on the Serial monitor. I use the 5xx JSON library and with 115200 bauds it works. Less than that it won’t. Anyway, it works as it is.

When I upload the same sketches but change send/receive boards, it doesn’t work. I tried different bauds and still no output, this time on UNO. Of course, I changed pins. I use SoftwareSerial for testing, as I can watch what comes in and out.

So, the same sketches, same boards, and it still works only to send data from ESp8266 to UNO, and not the other way.

Any idea what could be the problem? Or some other solution?

Thanks in advance.

When I upload the same sketches but change send/receive boards, it doesn't work. I tried different bauds and still no output, this time on UNO. Of course, I changed pins. I use SoftwareSerial for testing, as I can watch what comes in and out.

Sure, SoftwareSerial reception doesn't work above about 38400 baud on the AVR platform. The maximum baudrate for SoftwareSerial to work reliably on the AVR platform is 9600 baud, everything above that might work or might fail, it largely depends on the opposite party to more or less timing tolerant.

If you want high speed serial communication on the AVR platform, always use the hardware serial interface for it.