1.接线如下接线:
CH340 ESP8266 Arduino DataPin
TXD -> URXD 13
RXD -> UTXD 12
3.3V -> VCC 3.3V
3.3V -> CH_PD 3.3V
GND -> GND GND
2.编写代码
#include <SoftwareSerial.h> 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"); } void loop() { // run over and over if (mySerial.available()) { Serial.write(mySerial.read()); } if (Serial.available()) { mySerial.write(Serial.read()); } }
将其中的结束符调为NL和CR 波特率调为115200
发送AT时会收到回复OK