Mega sending data to Wemos D1 mini via I2C

I have a project where i have to send one way (later two way) data from Inhaos Mega Core to Wemos D1 mini. Here is a link to Mega Core:Everything done inhouse. For D1 Mini i think you all know about.

They are connected this way:
TX01 → D6
RX01 → D5

Right now both are connected to my PC via USB cables.

This is a sketch i use for Mega:

#include <ArduinoJson.h>
void setup() {
void loop() {
 StaticJsonBuffer<1000> jsonBuffer;
 JsonObject& root = jsonBuffer.createObject();
  root["data1"] = 100;
  root["data2"] = 200;

And this is a sketch i use for D1:

#include <SoftwareSerial.h>
SoftwareSerial s(D6,D5);
#include <ArduinoJson.h>

void setup() {
  // Initialize Serial port
  while (!Serial) continue;

void loop() {
 StaticJsonBuffer<1000> jsonBuffer;
  JsonObject& root = jsonBuffer.parseObject(s);
  if (root == JsonObject::invalid())

  Serial.println("JSON received and parsed");
  Serial.print("Data 1 ");
  int data1=root["data1"];
  Serial.print("Data 2 ");
  int data2=root["data2"];

When i upload both sketches, everything works. But when i reset one of the MCU’s, no matter which one, there is no data on Serial. I tried random reset both of them to get them communicate, but no luck. The only way to make them work again is to upload sketch again to both. Weird! Any suggestion?

Wires are soldered. And i do not use any of logic shifters.

No one has answered yet, because this is very confusing.

In the title you say that the communication is with I2C, but you use Serial.
You do not mention if you use a 3.3V ATmega2560 or a 5V ATmega2560.
On that website they say that the clock is 16 MHz. That is weird, a ATmega2560 at 16 MHz can not run at only 3.3V.
You may not connect a 5V TX from the ATmega2560 to a 3.3V ESP8266. The ATmega2560 can push between 20 mA and 40 mA into the RX pin of the ESP8266. Both chips might be damaged by now, so everything that happens is unpredictable unless you buy new hardware. You should have taken the warning in red serious at the bottom of the Wemos D1 mini page.
Using SoftwareSerial together with Serial might not always work.
Can the ESP8266 use 115200 baud with SoftwareSerial ?
You gave no link to the "ArduinoJson" library, so I don't know if you use it correctly.
On the ATmega2560, you are sailing blind without the use of the serial monitor. You could, for example, print the object that you have created.
On the ATmega2560, you use "if(Serial1.available()>0)". What are you waiting for ? Is the ESP8266 sending something ? Where does it do that ?
As far as I can tell, the wiring and the use of the JSON library are okay, but I don't know the JSON library so I'm not 100% sure.

My bad, i missed that for tittle. Sry

I use 5V Mega. I also have their prototyping board especially for this Mega Core. Jumper is on 5V.

I didn't use logic level shifters just because i made it work with Uno and Robotdyn WiFi D1, which is a board similar in size width Uno. Never had an issue. In Uno's case i used software serial in both boards width 9600 baud rate. This setup still works like charm. I do know that ESP8266 do not like 5V very much.

My goal is to feed D1 mini with data from Mega. Any suggestion would be nice. If you think i should go for some other type of connection, please say it. I will try it width level shifters if it will help.

Library i use is the one that you can get from IDE, Benoit Blanchon, V.5xxx

The sketch is from the net, which i get somewhere long ago, not sure where. It is as it is, width no modification. The same sketches works on Uno i mention.

If you have some noob-proof solution/suggestion i would be appreciated.

I read that a ESP8266 input can have 5V without getting damaged. So I was wrong, sorry :-[ That means your ATmega2560 and ESP8266 are not damaged.

Then this is the JSON library that you use: GitHub - bblanchon/ArduinoJson: 📟 JSON library for Arduino and embedded C++. Simple and efficient..

I think the most important question is: What are you waiting for with the "if(Serial1.available()>0)". What should be received and who will send it ? I think the Mega is not sending something.