ESP32-CAM Webcam Firmware: Build an OV2640 Streaming Camera
The esp32-cam web interface, with live preview and camera, Wi-Fi and network settings editable from the browser.
- ESP32 based camera board
- OV2640 camera module
- High power LED flash (optional)
- SSD1306 OLED display (optional)
- Motion detector (optional)
- External SPI RAM (optional)
What you will build and why it is useful
This guide walks you through flashing a standalone webcam firmware onto an ESP32 camera board fitted with an OV2640 sensor. When you are done, the board joins your Wi-Fi network (or creates its own access point), serves a web interface for configuration, and exposes a still-image capture endpoint and a live stream that any browser or network tool can consume.
The project started life as one of the example programs for Espressif's ESP-WHO face recognition framework. The author stripped out the face detection and recognition code to free up resources and remove the dependency on external SPI RAM, then added a set of practical features that turn the example into a usable device:
- An improved web interface
- Wi-Fi and network settings editable from the browser
- Persistent storage of camera and other settings in NVS
- An SSD1306 display driver that shows Wi-Fi connection details and frame rate
- An LED illuminator driver to control the intensity of an LED flash
- An mDNS server to announce camera services on the local network
- An NTP client and RTC for date and time
For robotics and monitoring projects this is a handy building block: a cheap camera node that you can drop onto a rover, point at a workbench, or mount in a test rig, and then pull frames from over HTTP. Keep expectations realistic, though. The README is clear that ESP32 resources for cameras are very limited and you should not expect the full resolutions and frame rates the OV2640 is capable of.
What you need
Hardware
- An ESP32 based camera board with an OV2640 camera module. The firmware is designed for this sensor specifically; the OV3660 is not supported because the author had no sensors available for testing.
- Optionally, a high power LED flash on the board. The firmware includes an illuminator driver with adjustable intensity.
- Optionally, an SSD1306 based OLED display. You choose the SDA and SCL pins in menuconfig.
- Optionally, external SPI RAM, if your board has it. It is not required, since the face recognition code that needed it was removed, but you can enable support in menuconfig.
- A USB connection to your computer for flashing.
Software
- The ESP-IDF toolchain and development framework. The README states that the source code works with the release/v4.0 branch, so check out that branch rather than the latest release.
- Git, to clone the repository with submodules.
- A shell on Linux or macOS, or the ESP-IDF Command Prompt on Windows 10.
The board you are using is selected under Camera Web Server -> Camera Pins in menuconfig, so you do not need to hand-edit pin definitions for supported boards.
Typical use cases
Mount the camera on a small robot and pull the port 81 MJPEG stream into your control software for a live driver's-eye view.
Poll the /capture endpoint from a script to grab stills of a 3D printer, bench or doorway at intervals.
Add an SSD1306 OLED to read Wi-Fi status and frame rate directly on the device while testing away from a laptop.
Use the LED intensity endpoint to switch on the onboard flash when inspecting dark enclosures or machinery.
How it works
Wi-Fi startup sequence. On boot, the firmware attempts to connect to Wi-Fi in a fixed order:
- Using the SSID and password stored in non-volatile storage (NVS).
- Using the default station (STA) SSID and password you provided in menuconfig.
- After five failed attempts in STA mode, it falls back to SoftAP mode and acts as its own access point.
In SoftAP mode you connect to the camera's network and point a browser at 192.168.4.1. There is no username or password. From the web interface you pick a Wi-Fi SSID, enter the password, and optionally set a static IP address and other network settings. Reboot the device for the new settings to take effect; they are then saved in NVS and used on the next boot.
Camera services. Once the camera is on your network, three URLs do the heavy lifting:
- Picture:
http://IP/capture - Stream:
http://IP:81/stream - Control LED:
http://IP/control?var=led_intensity&val=[0...255]
The stream runs on port 81, separate from the main web interface, which is a useful detail when you are writing a client or configuring a firewall. The LED control endpoint accepts an intensity from 0 to 255.
Extras. An mDNS server announces the camera's services on the local network. If NTP is enabled in menuconfig, the firmware syncs the RTC with your chosen NTP server and timezone. With an SSD1306 display enabled, the OLED shows information about the Wi-Fi connection and the current frame rate, which is handy for a headless rover where you cannot easily open the web page.
Camera settings are also stored in NVS, so adjustments you make through the web interface survive a power cycle.
Build and flash
1. Set up the ESP-IDF environment. Follow Espressif's getting started guide to install ESP-IDF, making sure you are on the release/v4.0 branch. Then export the environment and create a project folder:
cd /home/username/esp/esp-idf
. ./export.sh
cd ..
mkdir myprojects
cd myprojects
2. Clone the repository. The --recursive flag matters because the project pulls in submodules:
git clone --recursive https://github.com/bkeevil/esp32-cam.git
cd esp32-cam
3. Compress the web assets. The stylesheet, HTML and JavaScript in main/www need to be compressed before building:
cd main/www
./compress_pages.sh
cd ../..
4. Configure the firmware. Run idf.py menuconfig from the root of the source tree. Work through these settings:
- Serial Flasher Config -> Default serial port: pick your USB port.
- Camera Web Server -> Camera Pins: select your board.
- Camera Web Server -> LED Illuminator: enable if your board has an LED flash.
- Camera Web Server -> Wifi Settings: set default Wi-Fi credentials.
- Component Config -> SSD1306 Configuration: enable and set SDA/SCL pins if you have an OLED.
- Component Config -> ESP32 Specific -> Support for external, SPI-connected RAM: enable if your board has PSRAM.
- Font Configuration -> Store Font Partition: enables font overlays, using roughly 240K of flash.
- NTP configuration: enable NTP and pick a default server and timezone.
Save and exit when done.
5. Build, flash and monitor. If needed, clean first with idf.py fullclean. Then:
idf.py build
idf.py flash
idf.py monitor
The monitor output will show the Wi-Fi connection attempts described above, which is the quickest way to find the camera's IP address.
Partition table note. The author moved the partition table offset from 0x8000 to 0x18000. If you see Detected overlap at address: 0x8000 for file: partition_table/partition-table.bin, check that both sdkconfig and sdkconfig.defaults contain:
CONFIG_PARTITION_TABLE_OFFSET=0x18000
Windows 10. Use idf.py commands rather than make, launched from the ESP-IDF Command Prompt in the Start Menu. For example:
idf.py build
idf.py menuconfig
idf.py app
idf.py -p Portname app-flash
To simplify repeated builds, write your COM port to a file named build-windows-defaultcomport (no extension) and run the included PowerShell script:
echo COM15 > build-windows-defaultcomport
powershell.exe .\build-windows.ps1
Ideas to extend it and limitations
Ways to build on it
- Mount the board on a small rover or robot arm and consume
http://IP:81/streamfrom a controller application to get a live first-person view. - Use
http://IP/capturefrom a script to take periodic snapshots for a time-lapse or a simple workbench monitor. Because NTP is supported, the device has a correct clock for timestamping if you enable it. - Wire up an SSD1306 OLED so the camera displays its Wi-Fi status and frame rate without needing a browser, which is useful during field testing.
- Drive the LED flash through the
led_intensitycontrol endpoint to light a scene on demand. - The README notes that camera boards often include a motion detector and that the project intends compile-time support for optional component libraries. Contributions that further the project's goals are welcome, and the author continues to process pull requests.
Limitations to know before you start
- The project is no longer actively maintained. The author still merges pull requests and has invited anyone enthusiastic to take over.
- It targets the ESP-IDF release/v4.0 branch. Newer IDF versions are not mentioned as supported, so stick with v4.0 unless you are prepared to port it.
- Only the OV2640 sensor is supported; the OV3660 is explicitly excluded.
- Resolution and frame rate are constrained by the ESP32 itself. Do not expect the full capabilities of the OV2640.
- The web interface has no username or password, so treat it as a trusted-network device.
- The
esp_restart()software reboot from the web interface did not work on the author's boards, so you may need to unplug the device to force a restart after changing network settings.
esp32-cam is a lean, practical webcam firmware that improves on Espressif's camera example with a real configuration UI, persistent settings, mDNS, NTP and optional OLED and LED support. It is well suited to makers who want a no-frills HTTP camera for a robot or monitor and are comfortable with ESP-IDF menuconfig. Be aware that it is pinned to ESP-IDF v4.0 and no longer actively maintained, so expect to do some porting work if you need a newer toolchain.
Sources
github.combkeevil/esp32-cam — repository & READMEFacts in this article come from the project's public README and GitHub metadata at the time of writing. Images belong to their respective owners and link back to the original source.



