Hello. I have a project in which we have to make an Arduino Mega and an NodeMCU ESP32 to communicate bidirectionally.
We can send data from the ESP to Arduino, but not invers, so we can't send a response to the ESP32. I may need some advice on how to overcome this problem!
I will link the codes below. Thank you in advance!
ESP32 CODE
Well, start by drawing a schematic of your connections. Once you've thus told us what it is you're doing, we'll start. Right now, I fail to see why you need two serial links on each device.
C
So I cannot upload the image, because of company privacy VPN, but we have connected the GPIO1(TXD0) - 0 (RX0), GPIO1(TXD0) - 1 (TX0), GPIO15(TXD0) - 18 (RX1), GPIO13(TXD0) - 19 (TX1). We have used a two voltage dividers between the RX and TX to 3.3V.
I'm afraid I can't make head nor tails out of your description versus your pin definitions in your two codes. It makes no sense to me to define a bidirectional port for communication in one direction, and a different bidirectional port for communication in the other direction. In addition to that, you've got port pin numbers from one port in another port. I don't believe you can do that, and additionally, even if you could, why would you?
Look again at the pin assignments for Serial, Serial1, and Serial 2 in both units.
C