Hello, I'm brand new to both arduino and circuit creation but am a seasoned programmer and am having issues with an Arduino Mega 2560 clone board performing any types of communication with my ESP8266 board.
link to clone board
link to esp8266
I'm attempting to use hardware serial (Serial1) on ports 18 and 19 of the board to send the "AT" command to the esp such that I can recieve "OK" back and then go from there to do literally anything else, but its frustrating when the simplest command won't send.
I have this code as of now:
void setup() {
Serial.begin(9600); // Initialize Serial Monitor at 9600 baud, works
Serial1.begin(9600); // tried 9600, 57600, 74880, and 115200 here, none seem to work
// Test ESP8266 communication
delay(2000);
Serial.println("Setup complete, sending test command...");
delay(1000);
Serial1.print("AT+\r\n"); // Send AT command to ESP8266, found this on another forum post, before was "Serial1.println("AT");"
}
void loop() {
// Read from ESP8266 and send to Serial Monitor
if (Serial1.available()) {
String espData = Serial1.readString();
Serial.println("ESP says: " + espData);
}
// Read from Serial Monitor and send to ESP8266
if (Serial.available()) {
String userData = Serial.readString();
Serial1.println(userData);
}
}
I'm not sure how to make a diagram, but if you look at the layout of my esp specifically (on the amazon link) I have the 3.3v connected from the arduino to the 3.3v on the esp, as well as to the RST pin (enables the chip).
I have ground connected to the ground pin next to 3.3v pin on esp also from arduino
I have pin 19 of arduino connected to tx of esp
to ensure 3.3 tx from arduino to esp board:
pin 18 of arduino connected to rail 1 of bread board with 1kohm resistor here too
rail 2 of BB I have the other end of 1kohm resistor and one end of 2kohm resistor as well as a wire from rail 2 to rx of esp
rail 3 I have other end of 2kohm resistor and wire from rail 3 back to ground of arduino
That is it.
I will note that when I press the reset button on the esp board it shows in the Serial output "ESP says:" with a square icon appearing each time, but no matter the baud rate I can't get this icon to be anything else than just a square.
Also when the arduino sends anything to Serial the tx led blinks, but when it should be sending the AT command to Serial1, the tx light does not blink ever?
Let me know if I'm doing something wrong, again this is my third day learning any of this with the help of the internet and chatgpt