Upload Code to ESP32-CAM AI-Thinker using ESP32-CAM-MB USB Programmer (easiest way)

Learn how to upload code to the ESP32-CAM AI-Thinker board using the ESP32-CAM-MB micro USB programmer. This is the easiest way to program your ESP32-CAM board.

This micro USB programmer works like a shield that you attach to the ESP32-CAM board. The programmer comes with a USB socket that you connect directly to your computer.

Upload Code to ESP32-CAM AI-Thinker using ESP32-CAM-MB USB Programmer easiest way

The ESP32-CAM AI-Thinker module is an ESP32 development board with an OV2640 camera, microSD card support, on-board flash lamp and several GPIOs to connect peripherals. And it costs just a few bucks.

However, one of the biggest hassles when working with the ESP32-CAM Ai-Thinker module is uploading code to the board. The AI-Thinker board doesn’t have a built-in USB programmer. In previous tutorials we recommended using an FTDI programmer to connect to the board through the serial pins.

Additionally, you also needed to follow another two or three steps until successfully uploading the code. But, now you can simply use the ESP32-CAM-MB USB programmer and click the Upload button to successfully program your board. It’s that simple.

Getting the ESP32-CAM-MB USB Programmer

You can open the next link to check the available stores to get the ESP32-CAM-MB USB Programmer. The package includes the ESP32-CAM-MB Programmer and it might also include the ESP32-CAM board itself.

ESP32-CAM-MB Micro USB Programmer CH340G Serial Chip for OV2640

ESP32-CAM AI-Thinker MB Programmer

The ESP32-CAM AI-Thinker MB programmer is a shield that you attach to your ESP32-CAM board GPIOs. The following image shows the programmer and the ESP32-CAM side by side.

ESP32-CAM-MB Micro USB Programmer CH340G Serial Chip for OV2640

The programmer comes with the CH340C USB to serial chip.

ESP32-CAM-MB CH340G Serial Chip USB Converter

This allows you to program the ESP32-CAM using the USB port on the shield.

ESP32-CAM-MB CH340G Serial Chip Micro USB Port Programmer

Additionally, the shield also comes with a RESET and a BOOT (IO0) buttons. This may be useful to easily reset the ESP32-CAM or put it into flashing mode.

Program ESP32-CAM using the MB Programmer (Arduino IDE)

To program the ESP32-CAM board with Arduino IDE, you need to have Arduino IDE installed as well as the ESP32 add-on. Follow the next tutorial to install the ESP32 add-on, if you haven’t already:

Then, simply connect the MB programmer to the ESP32-CAM as shown in the following image.

ESP32-CAM-MB Micro USB Programmer CH340G Serial Chip OV2640 Camera

Then, connect the board to your computer using a USB cable.

After that, in your Arduino-IDE, follow the next steps:

1) Go to Tools Board and select AI-Thinker ESP32-CAM. You must have the ESP32 add-on installed. Otherwise, this board won’t show up on the Boards menu.

Select the AI-Thinker ESP32-CAM in Arduino IDE Tools Menu

2) Go to Tools Port and select the COM port the ESP32-CAM is connected to.

Note: if the board doesn’t show up, it means that you probably don’t have the CH340C drivers installed on your computer. Go to Google and search “CH340C drivers” followed by your operating system and install the drivers.

3) For demonstration purposes, you can copy the following blink sketch:

/*********
  Rui Santos
  Complete instructions at https://RandomNerdTutorials.com/esp32-cam-projects-ebook/
  
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*********/

// ledPin refers to ESP32-CAM GPIO 4 (flashlight)
const int ledPin = 4;

void setup() {
  // initialize digital pin ledPin as an output
  pinMode(ledPin, OUTPUT);
}

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(2000);
  digitalWrite(ledPin, LOW);
  delay(2000);
}

View raw code

This sketch, simply blinks the on-board flash LED.

4) Then, click the Upload button in your Arduino IDE.

Program ESP32-CAM with Arduino IDE

And that’s it!

You should get a message saying the code was successfully uploaded and your board should be blinking the LED flash.

ESP32-CAM-MB Micro USB Programmer CH340G Demonstration Testing

Wrapping Up

Using the ESP32-CAM AI-Thinker MB Programmer is the easiest way to program the ESP32-CAM board. You no longer have to use an FTDI programmer and experience timeout issues.

We hope you have found this article useful. You can try our projects with the ESP32-CAM:

Thanks for reading.



Build Web Server projects with the ESP32 and ESP8266 boards to control outputs and monitor sensors remotely. Learn HTML, CSS, JavaScript and client-server communication protocols DOWNLOAD »

Build Web Server projects with the ESP32 and ESP8266 boards to control outputs and monitor sensors remotely. Learn HTML, CSS, JavaScript and client-server communication protocols DOWNLOAD »


Enjoyed this project? Stay updated by subscribing our weekly newsletter!

55 thoughts on “Upload Code to ESP32-CAM AI-Thinker using ESP32-CAM-MB USB Programmer (easiest way)”

  1. hola espero pueda ayudar yo uso el USB ESP32-CAM-MB + ESP 32CAM cargo el código de prueba que enciende el led de la cámara y todo ok
    pero si cargo este proyecto Transmisión de video ESP32-CAM y reconocimiento facial con Arduino IDE el código sube bien pero el resultado es este
    ya probé todo y no hay manera de que funcione lo que no tengo claro es que mi ESP32CAM el modelo no creo que sea al-thinker en placa de mi esp 32 cam hay lo siguiente DM ESP32-S algún consejo ya no se que mas probar gracias
    ets Jun 8 2016 00:22:57

    rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:1
    load:0x3fff0018,len:4
    load:0x3fff001c,len:1216
    ho 0 tail 12 room 4
    load:0x40078000,len:9720
    ho 0 tail 12 room 4
    load:0x40080400,len:6352
    entry 0x400806b8

    [E][camera.c:1049] camera_probe(): Detected camera not supported.
    [E][camera.c:1249] esp_camera_init(): Camera probe failed with error 0x20004

    Reply
  2. This looks like a cool thing to have. The ESP32 cam is really good, compared to all the others that cost more. Ordered one from the eBay link.

    Reply
      • Pues yo no soy capaz de cargar el código como verás más arriba el error
        E][camera.c:1049] camera_probe(): Detected camera not supported.
        [E][camera.c:1249] esp_camera_init(): Camera probe failed with error 0x20004

        Reply
  3. Digging a bit deeper in the maze of AliExpress, there also appears to be an ESP32 camera with integrated CH340 USB connection. If you need only 1 or 2 ESP32 cams that is certainly an attractive option

    Reply
  4. Good evening. So this project is precisely timed. At the beginning of January I ordered these boards, at the end of the month it came and it is waiting to be implemented. So thanks a lot. I’m just remodeling the measurement with ESP and BM680 powered by LiPo and recharged solar. But once the next project with RPi and ePaper is complete, it will be another “night service” right away. But right now, it’s just for sitting at home. The test was negative again, which I wish you both (it’s about Covid). Lots of health and good mood.

    Reply
  5. Hmmmm… I tested the board out today. The kit comes with an ESP32 camera board. I was able to upload a sketch to it using the MB board interface. Sketch worked as expected.

    I was NOT able to upload a sketch to a AI Thinker Cam board using this MB board. I was able to upload the sketch to this AI Thinker Cam board using the trusty FTDI board.

    I wonder if it’s possible that only THEIR included ESP32 cams work with this MB board. I’ve contacted the seller through eBay to get their guidance.

    Reply
    • Specifically, I received the failure to connect error message:
      Connecting ….. ….. …… …….
      A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
      when I attempt to upload using the MB board to another ESP32 cam board.

      Reply
          • Hi.
            Today I tried it with another ESP32-CAM board, and it didn’t upload on the first try.
            I found out that you need to hold the programmer IO0 button and then press the ESP32-CAM on-board RST button when you start seeing the dots on the debugging window.
            It worked for me.
            Can you try it?
            If it works for you too, I’ll add a troubleshooting section to this article.
            Regards,
            Sara

          • I had success uploading a cam sketch to one of my other ESP32 cams. However, I found that after the sketch loaded, it wouldn’t run while still connected to the installer board. I tested it successfully while attached to my computer via FTDI cable. Pressing/holding IO0 and then pressing RST on the cam board was the way to go.
            The board didn’t cost very much, and I got another ESP32 cam out of it. I don’t know if it will replace my FTDI process, though.
            Thank you
            Don

          • BLUF: I think this is a Hardware Flow Control issue / C430 USB driver issue.

            The issue I am seeing with the ESP32-CAM-MB is that for some reason the RST line is being asserted on the CH430 by some of the serial port programs. I have parital success with the Arduino IDE, and puTTY but no luck with0 PyMAKR (VS Code). I have also tried HyperTerm and some other ones.

            The Windows 10 driver is set to have Flow Control as ‘None’, and the software is also set this way.

            The CH430 driver that I am using is ‘2019’ (CH431), and at some point, I will try the 2014 version. I might also try a Mac or Raspberry PI.

            I tried another PC, but had an issue getting PyMAKR to install properly.

  6. Hi Sara,
    I tried out two boards I received today with the MB, but I’m not getting my two older Cam boards loades neither. The boards are a litte bit different on the side where the flash LED is locaded. It looks like that there are two more resistors installed and there is also a 3V3 print???
    I trieded that out with the IO0 button, no luck.
    Willem

    Reply
    • Hi Kurt.
      Try holding the IO0 button on the programmer when you start seeing the dots on the debugging window and then press and release the ESP32-CAM on-board RESET button (not the programmer RST button).
      This worked for me.
      Regards,
      Sara

      Reply
  7. Hello,
    Today I tried to upload the code to the board using the MB module but when I do I get “Connecting …..______……..” Is this normal? Also do I need a special micro usb cable for uploading code? Do I simply follow the steps from the other comments (boot button and once ….. appear the on board reset from the esp32? I also have a problem installing the CH340 drivers, they won’t install any idea how to fix that?
    Thanks in advance
    Greetings
    Alex

    Reply
    • Hi.
      But does the code upload? Or do you get an uploading error after the …..____…… ?
      If that’s the case you need to do as mentioned previously.
      “Try holding the IO0 button on the programmer when you start seeing the dots on the debugging window and then press and release the ESP32-CAM on-board RESET button (not the programmer RST button).”
      Regards,
      Sara

      Reply
      • Hi Sara, I tried holding the IO0 button and then the ESP32 CAM on-board reset but the results in the monitor window are unreadable:
        16:29:57.478 -> ……………………………………….e⸮.RչA ⸮±⸮0⸮⸮⸮5SH⸮⸮⸮⸮:⸮⸮ (u]E⸮⸮⸮R⸮U⸮I⸮o⸮’⸮͠I⸮W⸮⸮⸮B⸮⸮⸮⸮⸮R⸮z*⸮T⸮iE%⸮_⸮Q⸮%U=}V⸮J⸮ȷX⸮⸮⸮g⸮⸮K⸮⸮⸮⸮l+⸮
        ⸮⸮.⸮⸮%ď{

        Reply
      • Whatever I try it does not work. In the Serial monitor I constantly see:
        rst:0x10 (RTCWDT_RTC_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
        flash read err, 1000
        ets_main.c 371
        ets Jun 8 2016 00:22:57

        If I upload a sketch I always get
        A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

        It’s a HK-ESP32-CAM-MB and the IO0 button on the programmer when you start seeing the dots on the debugging window and then press and release the ESP32-CAM on-board RESET button (not the programmer RST button) does not work either. Is my board just broken or is there another magic combination to make it work?

        Reply
        • Hi.
          I don’t know any other “magic” combination.
          But I can’t be sure that the board is the problem.
          Regards,
          Sara

          Reply
  8. The blinking code works well. But how to get the cameraWebServer example works? It upload fine but the serial monitor don’t give me any result.

    Reply
      • Tried to press the RST on board button (on ESP32-CAM board also on ESP32-CAM-MB), still nothing in the serial monitor.
        Should, i try to change the #define CAMERA_MODEL…. ?

        Reply
        • Hi.
          I don’t think it is related to that.
          It should be something about the serial communication.
          Check that you’re using the right baud rate and that you’re opening the Serial Monitor or the right port.
          Regards,
          Sara

          Reply
          • If the baud rate is not right, it usually show a scramble text, and also i already test to change the baud rate (the cameraWebServer example use 115200 baud rate), it is still not working (tried to press the rst button in each board everytime changing the baud rate). Also already double check the com port.

            But it solved by updating the arduino ide app to 1.8.13 . Thanks again.

  9. Hello.

    I recieved two ESP32-CAM boards and the two ESP32-CAM32-MB programers today. After choosing the AI Thinker ESP-cam board in the arduino IDE and selecting the active COM port I can’t upload the blink sketch..I get the same error as above : Failed to connect to ESP32: Timed out waiting for packet header.

    So I tried your suggestion:
    After seeing the dots in the arduino console I pressed the IO0 button (kept holding it down) and then pressed and released the reset button on the camera board (not on the programmer board) …but no luck.
    Also pressing IO2 button and releasing it and then pressing and releasing the camera-board RST button didn’t solve the problem. The behaviour is the same for the two boards.

    I tried different cables also. All cables work fine in uploading sketches on arduinos but I can’t upload the sketch on the ESP32-CAM.

    Reply
    • Hi.
      That’s weird. The programmer worked fine for me with the boards that came with it.
      For other boards, I needed to do that with the buttons. But I was always able to upload the code.
      Can you try selecting another board. You can try the ESP32 Wrover module.
      Regards,
      Sar

      Reply
      • Same here, reset via MB (regardless if pressing the button or sending RTS signal) works only with the ESP32 CAM module that arrived with the MB and not with the other modules. Flash button or DTR signal for activating the bootloader work well with all the boards.

        Reply
  10. At the moment I have just these boards but monday I will recieve a FTDI programmer so I will try with that one to figure out whats wrong.

    Reply
  11. I can upload the firmware using the MB without pressing IO0 (flash) or RST button with both PlatformIO and Arduino IDE but the microcontroller doesn’t work when PlatformIO serial monitor is opened. Seems as RST and IO0 are pulled LOW by RTS and/or DTR and PlatformIO serial monitor pulls RST LOW which Arduino serial monitor doesn’t.

    Reply
    • With PlatformIO these lines have to be added to platformio.ini:

      monitor_rts = 0
      monitor_dtr = 0

      However, reset via MB (regardless if pressing the button or sending RTS signal) works only with the ESP32 CAM module that arrived with the MB and not with the other modules. I am still trying to find out the reason why reset button (and RTS) doesn’t work with other boards.

      Reply
  12. Hello everybody,

    anyone has an idea on how to connect the esp32-cam to my router via ethernet?
    If you can’t connect any ethernet module to the board directly, maybe there is an way to send it to another board, that is connected via ethernet or something else?

    I searched the whole internet, but I couldn’t find anything so far…

    Reply
    • He Felix,

      i’ve used the esp32-cam-mb (the one with usb) and used the webcam setting from this site.
      (ESP32-CAM Video Streaming Web Server (works with Home Assistant) and it bounded with my wireless router. In the serial monitor you can red the ip address. Working nicely but don’t expect much from the camera although :=)

      Reply
  13. I experienced similar issues and trued several of the suggestions – seemingly not working . But after all this, I just put a 4Gb micro SD card in the slot and wham!! – 25-35fps using the AI Thinker webserver example – no issues or noticeable time lag at the smaller screen sizes. Using Arduino IDE and just compiling and upload – no need to hold down the boot button. Very handy piece of kit for uploading but no GPIO pins exposed so you need to move it to a breadboard after uploading to try the projects out.

    Reply
  14. Hello everyone and without the intention of offending anyone, I have to say that the esp32 CAM is a crappy camera if or if it hangs every 2 x 3 it works when a fiasco feels like it

    Reply
    • Data transfer from the camera to the ESP32 is slow or even hangs when the voltage drops because of power supply which can’t supply enough current without dropping the voltage or if the camera overheats. With good power supply ESP32 CAM works very well.

      FTDI module can’t supply enough current via 3V3 pin, take 5V from the 5V/3.3V jumper pin and connect it to 5V input. Jumper still has to be in the 3V3 position and all other voltage levels must be 3.3 V.

      3.3 V output from breadboard voltage module is too weak as well, use 5 V. Most of laptop USB ports are also too weak but everything works well when using powered USB hub. USB cables must be good too, with some USB cables the ESP32 CAM will reset whenever starting wifi connection.

      Once there is enough power the ESP32 CAM modules work very reliable.

      Reply
  15. I bought esp32-cam and its programmer. But it is not a ai thinker. I get these errors after loading the program . I’ve tried a lot of different pin connections. Either does not recognize the camera or gives this error. What should i do to make it work.

    Error code:
    Camera Ready! Use ‘http://192.168.1.106’ to connect
    [E][camera.c:1483] esp_camera_fb_get(): Failed to get the frame on time!
    Camera capture failed

    Reply
    • Hi.

      Here’s what one of our readers suggested for that problem:

      I found out the solution for my case, I hope many others can read this message because I have seen many people frustrated on the Internet with the error ” esp_camera_fb_get(): Failed to get the frame on time!”.

      Everything was solved just changing some parameters:


      config.xclk_freq_hz = 5000000;

      config.frame_size = FRAMESIZE_SVGA;

      I hope this helps.
      Regards,
      Sara

      Reply
    • Hey.
      I had the same problem with one ESP32-Cam, just reseated the little ribbon cable and the camera started to work. Gived a try.

      Kurt

      Reply
  16. Hello Sara (et al)! I think I already found my answer by reading between the lines in a couple of comments. But my question is do you need to have the esp32 cam MB programmer module attached to the camera module during operation? Thank you

    Reply
  17. i bought 3 of these mb programmers with esp32-cams from aliexpress.2 of the cams kept giving me upload errors and i can’t get them to work with the programmers.
    one of the cameras programmed like a champ on all 3 programmer boards, didn’t have to press any buttons. I kind of remember having to add a capacitor when i get these type of errors on these cams .I am not saying the
    cameras are bad yet , they may need this added capacitor. Thanks for all the
    great info you have always provided.

    Reply
    • Hi Richard.
      I’m sorry for the issues.
      I didn’t have any troubles with the programmers I have.
      However, we needed to press some buttons to make them work with other cameras (the ones that didn’t come with the programmer).
      Regards,
      Sara

      Reply
  18. These models of ESP32-CAM-MB programmer connect RTS to EN and DTR to BOOT, but don’t include the transistor network required to not reset the board when both RTS and DTR are asserted at the same time (which most serial terminals do on connection, even when hardware flow control is disabled – this includes putty, pymakr and ampy). This causes it to go into an unusable reset state whenever you try to connect using these apps. Yat is able to connect properly and go into REPL, as it has manual control over RTS and DTR, but not being able to use ampy or pymakr to upload code makes it a lot harder to develop.

    I worked around this by removing the two SMD diodes connecting the RTS and DTR lines from the CH340 to the EN and BOOT buttons and pins (these are physically located between the MicroUSB port and the IC). With those lines disconnected you have to use the physical buttons to reboot go into the bootloader, but when using micropython that’s rarely needed anyway.

    Reply

Leave a Reply to Kurt Hennig Cancel reply

Download our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.