How to connect Nodemcu(ESP8266) and arduino Mega

Hi guys, I have a problem. I am currently working on a IoT project for the university, basically, I have built a system with a Nodemcu and some Rfid(RC522) readers and tags to make a smart system for the canteen, and a BotTelegram for the interaction with the customers. Everything is working perfectly on the Nodemcu, but now I have a problem because I need to use more tags and i need more gipio, so i decided to move all the system to an Arduino mega, but I need the internet connection and the BotTelegram integration.

Knowing that I need just the code from the tag to use the bot telegram and send data over the internet to the Bot, I just want to connect the Arduino and the Nodemcu with serial communication or i2c ecc. to send a vector/string/ or whatever from the Arduino to the Nodemcu. Can you help me how to do that? Should be a simple thing but I don't know how to do that.

NodeMCU GPIO expander: Overcome NodeMCU Limitations with GPIO Expander - Making It Up

thanks, this is a cool device, but I prefer to use the serial or i2c communication, can you help me to send an array from the Arduino to the nodemcu?

I don't have a NodeMCU dev kit.

In my opinion, I'd rather use the CPU capability of the ESP8266 than the Arduino's which is essentially what you want to do.

I Know that the NodeMcu is powerful than the arduino, but i am forced to use the arduino mega because of his pins

AndreaLun:
I Know that the NodeMcu is powerful than the arduino, but i am forced to use the arduino mega because of his pins

No, you are not.

Adding more GPIO pins to the NodeMCU board means you keep most of your code and get more GPIO pins.

Do you enjoy making things difficult for yourself?

The real problem is that I have to deliver the project to the professor in 2 days, and I can not wait for the components to be shipped. That's why I have to try to send a value from the Arduino to the nodemcu with a protocol (serial or i2c).

AndreaLun:
The real problem is that I have to deliver the project to the professor in 2 days, and I can not wait for the components to be shipped. That's why I have to try to send a value from the Arduino to the nodemcu with a protocol (serial or i2c).

Then I guess you had better try to re-write your code very quickly.

Search for examples on how to use the NodeMCU board as a slave to the Arduino Mega.
If it is like the ESP-01 modules, the connection will be via serial port.

The problem is that, rewriting the code should not be a problem, however I can not understand how to communicate the two cards via serial or via i2c, it should be very simple but not even found a guide that would help me to do it. technically I would simply keep the code to send a string from the arduino to the nodemcu. Can you help me?

AndreaLun:
The problem is that, rewriting the code should not be a problem, however I can not understand how to communicate the two cards via serial or via i2c, it should be very simple but not even found a guide that would help me to do it. technically I would simply keep the code to send a string from the arduino to the nodemcu. Can you help me?

I don't have a NodeMCU.

They are both self-contained units.
You need to turn the NodeMCU into purely a wifi "shield" for the Arduino Mega.
I don't know whether this is doable or not.
If you have found information, then I suggest you start reading it.

No, i think is way simpler send via serial from the mega to the nodemcu the Int array that i need, but i don't know how to do that

AndreaLun:
No, i think is way simpler send via serial from the mega to the nodemcu the Int array that i need, but i don't know how to do that

Whatever you think.

I would imagine you would need to write a sketch for the Arduino where it is sitting constantly monitoring the serial port for a query from the NodeMCU board and then responding.

Man, i know that is not the best solution but i have no time to modify the code, so for now is better splittin the code in the ardiono mega and the nodemcu.

but the problem remain, how to send data via serial, can you help me? i just need a code to send an array from arduino to nodemcu

How to connect Nodemcu to Arduino mega 2560 for home automation purpose?
If anyone have any idea related to this please reply for it!
Thanks.