While working with microcontroller boards like ESP32-CAM, Arduino Nano or ESP8266 NodeMCU, and other ESP32 boards I came across several problems while uploading the program code. These devices are either connected through USB(using USB To RS232/ TTL Converter module) or using the pins on the board directly. I am writing this to remember and share info on what kind of problems and errors I got and how I solved the uploading problems of these board. Hopefully it is useful to you and if you had similar experience and found solution and want to share, please let me know. Thanks.
So this blog post is all about troubleshooting uploading problem with ESP32-CAM, ESP32 and ESP8266 NodeMCU boards.
ESP32-CAM module
1. A fatal error occurred: Could not open COM4, the port doesn't exist
Failed uploading: uploading error: exit status 2
Solution:
Here I what I did to solve this problem while uploading code.
The ESP32 CAM module requires pl2303hxa USB driver
While uploading the code you might encounter the message: PL2303HXA. Phased out since 2012. Please contact your supplier. At the time I was using windows 10 and the solution was to update the driver as shown in the video below.
2. A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x00): Possible serial noise or corruption.
Failed uploading: uploading error: exit status 2
Solution:
This source to this error could be many but it suggest that the PC is able to see ESP32-CAM module but the communication is not happening because of some faulty communication lines. I tried many things and ended up thinking that there is not enough voltage or current required by the ESP32 cam module. So what I did to solve this problem is to use diy breadboard 5V power supply module instead of the USB 5V power. You can use other +5V voltage regulator. The connection is as shown below and note that the usb ground and the ESP32-CAM module ground and ground of the external power supply in this case the breadboard +5V supply must be connected.
One thing I noticed when I got this problem is that, normally, when the reset button is pressed during the uploading process the ESP32-CAM bright led should turn on/off once, but when I encountered this error, the led did not turned on/off.
After connecting the ESP 32 cam module to external +5V with common ground, I was able to successfully upload the code into the ESP32-CAM. See the following video of supply ESP32-CAM module with external power supply.
Next time I will record the problem of uploading code to ESP8266 NodeMCU and ESP32 Dev Kit / ESP Wroom 32 which uses the CP210x usb driver.
Additional resources: