unsigned long int baud = 115200;
void setup() {
Serial.begin(baud);
Serial1.begin(baud);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
}
void loop() {
if (Serial.baud() != baud) {
baud = Serial.baud();
Serial1.begin(baud);
}
if (Serial1.available()) {
Serial.write(Serial1.read());
}
if (Serial.available()) {
Serial1.write(Serial.read());
}
}
I am resetting and putting the ESP module into program mode externally. I have tested with a normal USB to UART converter and it all works fine, but when I try with the Leonardo, it fails. Am I missing something? Below is the error code I get when I try.
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
warning: espcomm_sync failed
error: espcomm_open failed