Answer the question
In order to leave comments, you need to log in
ESP8266 (ESP-01) does not listen to Arduino. What to do?
I'm trying to connect Arduino Mega and ESP8266 (ESP-01). For example, I took a simple ping program that listens to two ports (one USB-Arduino port, the second Arduino-ESP port), and duplicates information from them to each other. Here is the program itself:
#include <SoftwareSerial.h>
#define RX 19
#define TX 18
SoftwareSerial esp8266(RX, TX);
void setup() {
Serial.begin(115200);
esp8266.begin(115200);
}
void loop() {
if (esp8266.available()) {
Serial.write(esp8266.read());
}
if (Serial.available()) {
esp8266.write(Serial.read());
}
}
Answer the question
In order to leave comments, you need to log in
As a result, I solved the problem differently: instead of declaring a software UART through SoftwareSerial, I used an already existing hardware Serial1 (the same pins that I tried to use in the original program). To be honest, I still do not understand why one works and the other does not, when the result should be the same (I mean the result of declaring Serial1 and declaring via SoftwareSerial, using the same pins). If anyone knows, please tell me.
The working code looks like this:
#define esp Serial1
void setup()
{
Serial.begin(9600);
esp.begin(115200);
}
void loop()
{
if (esp.available()) {
Serial.write(esp.read());
}
if (Serial.available()) {
esp.write(Serial.read());
}
}
Speeds and bit/parity must match on both devices.
And we must take into account that the arduins IO work at 5 volts, and for ESP - at 3.3, coordination is needed.
SoftwareSerial works disgustingly on 115200, in fact it sends and receives garbage. With SoftwareSerial, I managed to make ESP-01 friends only on 38400. There is an AltSoftSerial library, it more or less rose to 57600.
In order to switch ESP, you need to enter the AT command: AT+UART_DEF=38400,8,1,0,0
Do not forget about matching the levels of logic and power, simply connecting the ESP to the Arduino will burn the ESP.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question