I have the Mega2560, and am trying to send an email through the ESP8266 12e, however it seems that the two boards are not connecting with each other.
I have the RX and TX of the ESP8266 connected to RX1 and TX1, and EN and VCC connected to the 3.3V pin of the Mega2560.
I then run the below code, and when I send "AT" I get no responses.
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial1.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial1.available())
Serial.write(Serial1.read());
if (Serial.available())
Serial1.write(Serial.read());
}
I have tried changing the baud rate and nothing seems to work.
Hopefully it is readable, but I went ahead and did the connections myself on the attached image (not professional grade though) The original was one from a components101.com website.
Sorry, I am using the ESP12E, I thought that it the 12E was the version of the ESP8266.
As for TX to TX and RX to RX, what I read online said that for this board you were supposed to do them this way, however, as I did my testing, I would always swap them each time just in case (though nothing would work), I'll switch them though, thanks for the heads up!
As for my code, I think I am getting which serial is for which confused, I am fairly new to Arduino. If I want to send commands over the Arduino IDE terminal to test for connection (such as the "AT" command) how should I setup the code? When I tried using the "Serial.swap();" I got "'class HardwareSerial' has no member named 'swap'" is there something else I need to add, such as including a library?
To clarify, when I do the swap function, I should have the ESP12E GPIO15 and 13 be connected to the Mega2560 TX1 and RX1, correct?
your sketch is a SerialPassthrough sketch. so the commands from Serial Monitor are copied in Mega to esp8266. the wiring RX to RX is used if the ATmega MCU is not used and the esp8266 is connected to the USB chip of the board over the common RX/TX pins.
the first comment by PerryBebbington is not applicable here. it is about esp8266 sketches. you have AT firmware in the esp8266.
so wire the esp8266 to RX1, TX1 of the Mega crossed RX to TX. do not forget to wire the ground together.
and don't forget in Serial Monitor to set the line ending to 'both'
GolamMostafa:
There is something RONG that is going on among you, I, and this Thread!
I don't know what is RONG, but I think if someone understands the line ending characters problematic, then the meaning of 'both' is clear. you can use no line ending, one of the two possible line ending characters or both line ending characters .
It is like if someone asks with hands behind the back. "In which hand I have a candy?"
This is a perfect example of why taking a few extra seconds to be very specific in your forum writings, documentation, tutorials, etc. can end up saving so much time and confusion in the end.
To have written:
Select "Both NL & CR" from the line ending menu at the bottom of the Serial Monitor window".
would take so little extra time for anyone with a reasonable WPM typing rate and leaves no room for misinterpretation.
I usually do this for the sake of the confused beginners because I know from personal experience how incredibly frustrating it can be trying to follow instructions when the author left out things that were obvious to them. When everything is going wrong, it is a great comfort to have extremely explicit instructions that don't assume anything.