ESP8266 and Arduino serial communication

1. The wiring is as follows:

CH340 ESP8266 Arduino DataPin
TXD -> URXD    13
RXD -> UTXD    12
3.3V -> 3.3V    br> 3.3V -> CH_PD    3.3V
GND -> GND     GND


2. Write code

#include 

SoftwareSerial mySerial(
13, 12); // RX, TX

void setup () {
Serial.begin(115200);
Serial.println(
"Hello, serial!");

// set the data rate for the SoftwareSerial port
mySerial.begin(115200);
mySerial.println(
"AT< span style="color: #800000">");
}

void loop() {// run over and over
if (mySerial.available()) {
Serial.write(mySerial. read());
}
if (Serial.available( )) {
mySerial.write(Serial.read());
}
} Set the terminator to NL and CR, the baud rate is 115200, and you will receive it when you send AT Reply OK

#include 

SoftwareSerial mySerial(
13, 12); // RX, TX

void setup() {
Serial.begin(115200); < span style="color: #000000">
Serial.println("Hello ,serial!");

// set the data rate for the SoftwareSerial port
mySerial.begin(115200);
mySerial.println(
"< /span>AT");
}

< span style="color: #0000ff">void
loop() {// run over and over
if (mySerial.available()) {
Serial. write(mySerial.read());
}
if ( Serial.available()) {
mySerial.write(Serial.read());
}
} Set the terminator to NL and CR, set the baud rate to 115200 Send AT You will receive a reply OK

Leave a Comment

Your email address will not be published.