Hi All
I am a bloody beginner to micro controller programming and have an issue with the following project: I would like to use a Leonardo board as USB to UART bridge to program an ESP32-Cam board. In order for this I have tried using the following code, which is based on "USB/UART bride for Arduino Leonardo", written by Uli Koehler:
/*
USB/UART bride for Arduino Leonardo
Originally written by Uli Koehler in 2015
Published on techoverflow.net
Revision 1.0
Published under the public domain (CC 1.0 Universal)
*/
void setup() {
// Adjust baudrate here
Serial.begin(115200);
Serial1.begin(115200);
//Wait until USB CDC port connects
while (!Serial) {
}
Serial.write("USB-UART bridge ready.\r\n");
}
void loop() {
//Copy byte incoming via TTL serial
if (Serial1.available() > 0) {
Serial.write(Serial1.read());
}
//Copy byte incoming via CDC serial
if (Serial.available() > 0) {
Serial1.write(Serial.read());
}
}
I have successfully uploaded the sketch to the Leonardo board using port "COM4 (Arduino Leonardo)" and connected the Leonardo board to the ESP32-Cam board using the following schema:
Leonardo / ESP32-Cam
GND --> GND
5V --> 5V
TX --> voltage divider (1KΩ/2,2KΩ) --> U0RXD
RX --> 1KΩ --> U0TXD
On the ESP32-Cam board I have set a jumper for boot mode (GND --> GPIO0).
Now I would like to upload the following "Blink Example" sketch to the ESP32-Cam:
void setup() {
pinMode(flash, OUTPUT);
}
void loop() {
digitalWrite(flash, HIGH);
delay(1000);
digitalWrite(flash, LOW);
delay(1000);
}
When trying to upload the sketch using port COM4 the RX-LED on the Leonardo flashes once, but the Arduino EDI reports:
A serial exception error occurred: Write timeout
Note: This error originates from pySerial. It is likely not a problem with esptool, but with the hardware connection or drivers.
For troubleshooting steps visit: Troubleshooting - ESP32 - — esptool.py latest documentation
Failed uploading: uploading error: exit status 1
Have I made anything wrong?
How can the Leonardo board know whether I want to upload a sketch to the Leonardo board or send the data to the UART interface (ultimately to the ESP32-Cam)?
In Arduino EDI "Blink Example" project the target board is set to "AI Thinker ESP32-CAM". I have also tried "Upload Using Programmer", without success.
Any help would be greatly appreciated.
Edit:
I am now receiving a different error message when trying to upload the ESP32-Cam code:
Sketch uses 302166 bytes (9%) of program storage space. Maximum is 3145728 bytes.
Global variables use 20576 bytes (6%) of dynamic memory, leaving 307104 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.8.1
Serial port COM4
Connecting......................................
A fatal error occurred: Failed to connect to ESP32: No serial data received.
For troubleshooting steps visit: Troubleshooting - ESP32 - — esptool.py latest documentation
Failed uploading: uploading error: exit status 2
