Skip to content

Flashing the ESP32-CAM

Time
30 min
Difficulty
Medium

What you'll learn

  • How a board without USB is programmed through a USB-TTL adapter
  • How to put an ESP32 into download mode by hand
  • Why the first upload should erase the whole flash

The ESP32-CAM has no USB port, so you program it through the USB-TTL adapter. In the tested setup the adapter stays connected afterwards: it powers the camera board and gives you its debug console.

Unplug the adapter from the computer first.

Wiring diagram (schematic). The table below lists every wire.ESP32-CAMUSB-TTL adapter5V5VGNDGNDU0R (GPIO3)TXU0T (GPIO1)RX

Schematic only: each board shows just the pins in use, not in their physical order. Always match the labels printed on your board. Dashed wires are not yet tested.

USB-TTL adapter to ESP32-CAM: 4 wires
FromToSignalNotes
USB-TTL adapter5VESP32-CAM5VPower (5V)In the tested setup this is the CAM's only power supply. The DevKit's 5V is not connected to the CAM.
USB-TTL adapterGNDESP32-CAMGNDGround
USB-TTL adapterTXESP32-CAMU0R (GPIO3)Data to the CAM (uploads and console commands)With the adapter set to 5V, this line carries 5V logic, above the ESP32's rating. A 1 kΩ / 2 kΩ divider is recommended; not fitted on the tested build.
ESP32-CAMU0T (GPIO1)USB-TTL adapterRXData from the CAM (debug console)

The adapter’s TX goes to the camera board’s U0R (receive), and its RX to U0T (transmit): each side’s transmit feeds the other’s receive.

Open the sketch and pick the board and port

Section titled “Open the sketch and pick the board and port”
  1. In the Arduino IDE, open airgap_qrcam with File → Open….
  2. Select Tools → Board → esp32 → AI Thinker ESP32-CAM.
  3. Open Tools → Port before and after plugging the adapter into the computer. The entry that appears is the adapter’s port: select it. On Windows it is a COM port, and on Linux usually something like /dev/ttyUSB0.

The camera board enters download mode (ready to receive new firmware) only if its GPIO0 pin is connected to ground when it starts.

  1. Bridge GPIO0 to GND with a jumper wire. Use a real GND pin, never the one labelled GND/R.
  2. Press the camera board’s RESET button.
  3. Click Upload (the arrow button). The IDE compiles the sketch, then sends it to the board. Watch the Output panel until the upload has finished.
  4. Remove the bridge when the upload has finished.
  5. Press RESET again to start the new firmware.

You don’t need to set anything else:

  • The AI Thinker ESP32-CAM board settings enable the board’s PSRAM and give the firmware a large app partition.
  • The sketch folder contains its own partitions.csv, which the ESP32 core uses automatically. It has no area for crash dumps, so a crash can never write memory contents to flash.

The IDE shows the error in the Output panel.

  • Invalid head of packet (0xF9): the board wasn’t in download mode, usually because the GPIO0 bridge wasn’t making contact at reset. Reseat the bridge, press RESET and try again.
  • “Access is denied” or “port busy”: another program, such as a serial terminal, has the port open. Close it first. Only one program can use a port at a time.

After the reset, the camera board starts scanning for QR codes. The full check comes later, once the DevKit is flashed too: its Scan test screen shows what the camera reads.

If the camera board keeps rebooting with Detected camera not supported in its console, unplug the power, reseat the camera’s ribbon cable, and power it up again. That fixed it in testing.

  • The camera firmware uploaded without errors, and the GPIO0 bridge is removed.
  • Erase All Flash Before Sketch Upload is back to Disabled.
  • The adapter stays connected and powers the camera board.
  • The DevKit’s 5V is not connected to the camera board.