Using the ESP32-CAM-MB programmer to flash any ESP32 board
The USB port of the ESP32 board stopped working and there's no spare FTDI adapter? The ESP32-CAM saves the day since it comes with the ESP32-CAM-MB Programmer.
The ESP32-CAM-MB is a micro USB (or recently, USB-C also) programmer that you attach to the ESP32-CAM board (also known as AI Thinker Cam Board). The ESP32-CAM-MB programmer is a shield for the ESP32-CAM, with the same form factor, as the ESP32-CAM. It comes with a USB port that you connect directly to your computer. You can upload code to the ESP32-CAM board (or flash your ESP32-CAM), using the ESP32-CAM-MB programmer easily, without having to deal with manual wiring.
If you happen to have an ESP32-CAM board, it is very likely you also have the ESP32-CAM-MB micro USB programmer, as they are usually sold together with ESP32-CAM. You can also buy the programmer separately, as well as other accessories, such as an Antenna or the OV2640 Camera.
But did you know, you can use the ESP32-CAM-MB to flash any ESP32 module or board? Today we are going to explore the whys and hows.
What kind of programmer the ESP32-CAM-MB is? #
So we know that the ESP32-CAM-MB is a programmer, used for flashing the ESP32-CAM boards. But what is happening behind the scenes, and how does this programmer work?..
ESP32-CAM-MB is a simple board, that utilizes the CH340G USB-to-UART chip for the Serial Communication between your computer and ESP32-CAM board.
Other than that, it includes the wiring of CH340G chip to the ESP32-CAM board, as well as some buttons - IO0 and RST.
Advantages of using the ESP32-CAM-MB #
Simplifying Serial Communication: Say goodbye to tangled wires and confusing setups! With ESP32-CAM-MB, Serial Communication with the ESP32-CAM becomes a walk in the park. And that is a plug-and-play simplicity - just connect the USB cable and communicate with the ESP32-CAM.
Streamlining Flashing Processes: With the ESP32-CAM-MB flashing ESP32-CAM devices becomes as easy as hitting the upload button on your IDE.
ESP32-CAM-MB Pinout #
Unfortunately, the ESP32-CAM-MB board does not have any markings for pins. But since the ESP32-CAM, which has the pin markings, plugs into the ESP32-CAM-MB, we can just look at the ESP32-CAM board and decide the pins on the ESP32-CAM-MB programmer.
Therefore the ESP32-CAM-MB pin-out is the same as ESP32-CAM board.
Flash any ESP32 with ESP32-CAM-MB - Wiring #
By looking at the traces on ESP32-CAM-MB PCB, we could see that actually not all the pins are wired. But that is not a problem, since to program any ESP32 chip, we will need only RX, TX, 5V, GND and optionally GPIO 0 pins, which are all connected.
The pins marked as green are connected and ready for use, while the ones marked as red are not connected.
So the ESP32-CAM-MB uses a CH340G USB-to-UART chip and has it wired to RX and TX pins, meaning it is suitable to program any ESP32 chip, not only the ESP32-CAM board.
However, since we cannot just plug any board into ESP32-CAM-MB as a shield, we will have to connect the pins manually.
Normally the connection should be as follows:
ESP32 | ESP32-CAM-MB |
---|---|
VCC | 5V |
GND | GND |
RX | TX |
TX | RX |
GPIO 0 | GND |
Make sure not to use long wires, as the Serial Communication is pretty sensitive to noise.
Flash any ESP32 with ESP32-CAM-MB - Flashing #
To upload the code to ESP32, simply use your preferred method you always use - there is no difference. Therefore you can use Esptool, Arduino IDE, ESP-IDF, Platform.io, you name it...
For the sake of an easy example, we will demonstrate uploading the code with Arduino IDE.
Connect ESP32-CAM-MB to the computer
Open ESP32 example code
In Arduino IDE, select "File"->"Examples"->"ESP32"->"Arduino Stack Trace".
- Select ESP32 board
Select a Serial Port and Board.
- Upload
Troubleshooting #
- If the upload fails, often you need to manually select the Upload Speed (Baud Rate). Try different options and see if any of it works.
If selecting the Upload Speed (baud rate) doesn't help, make sure the GPIO 0 is connected to the ground (GND) before plugging the ESP32-CAM-MB into the computer.
People often report that the power supplied by the ESP32-CAM-MB 5V pin is not enough to power the ESP32 chip for code upload. Try connecting the separate power supply to ESP32 VCC and GND pins.
Flashing ESP32 D1 Mini with ESP32-CAM-MB #
For this example, we will flash the ESP32 D1 Mini board, using the ESP32-CAM-MB programmer.
Connect the pins as shown in the picture below and upload the code to the ESP32 board as described above - "Flash any ESP32 with ESP32-CAM-MB - Flashing".
To be able to flash the ESP32 D1 Mini, I had to select the "230400" Upload Speed (baud rate).
Why flash with ESP32-CAM-MB and Other ways to flash ESP32 #
Now some of you might wonder, why would you flash other boards than the ESP32-CAM with the ESP32-CAM-MB. Well, there are several reasons:
- Programming ESP32 chip directly - Bare SoC without the development board
- ESP32 Development board with no USB-to-UART - Some ESP32 Development boards doesn't have USB-to-UART integrated
- The USB-to-UART chip is broken - Quite an often occurrence with the Chinese clones. If you cannot flash the board when plugged in the board's USN port - doesn't mean the ESP32 SoC is broken.
Using the ESP32-CAM-MB is just one of the many ways to flash your ESP32. You can also use FTDI, other boards with CH340G or CP2102 chips, etc.
Frequently Asked Questions (FAQ) #
Below you can find answers to some most frequently asked questions.
Can I use ESP32-CAM-MB to program other types of ESP32?
How to flash ESP32 with ESP32-CAM-MB Progammer?
Can I program other development boards than ESP32 D1 Mini?
What to do if the connection with ESP32 is not working when using ESP32-CAM-MB?
- Check the pins connection
- Make sure GPIO 0 on ESP32 is connected to Ground (GND), before powering up the ESP32
- Try changing Upload Speed (Baud Rate)
- Try using external power source
- Follow Troubleshooting steps
Conclusion #
Sometimes the USB-to-Serial chip on ESP32 development board dies, and you go looking for the FTDI controller, but you cannot find it. Then you remember you had the ESP32-CAM-MB programmer and wondered, could I use that to flash the ESP32 board?
In this article, we have figured out that the ESP32-CAM-MB programmer can be used to program not only the ESP32-CAM boards but practically any ESP32 chip or development board.
We have gone through the steps of identifying the ESP32-CAM-MB pins, connecting them to the ESP32 development board and flashing an example code to the ESP32.