esp32.diy

ESP32-CAM MicroPython 2022: Live Streaming Webcam Server

Oct 13, 2026 · 4 min read

Intermediate 243 stars 43 forks Python MIT Updated 2024-01-21

ESP32-CAM board with OV2640 camera module, ready for MicroPython firmware flashing

TL;DR This project gives the ESP32-CAM board a custom MicroPython firmware with full OV2640 camera support, then runs a lightweight Python webcam server that streams live video, serves snapshots, and enables timelapse capture over your local WiFi network. Setup takes about 30 minutes and requires only a Thonny IDE and an FTDI adapter.
What you need
  • ESP32-Camera board
  • OV2640 camera module
  • FTDI USB UART adapter
BoardESP32-Camera
CameraOV2640 with PSRAM
FrameworkMicroPython v1.18
LanguagePython
LicenseMIT
DifficultyIntermediate

What You Will Build

You will turn a bare ESP32-CAM board into a self-hosted webcam server reachable from any browser on your local network. Once running, the server lets you view a live stream, grab still photos, rotate the image, and even record timelapse video — all without any cloud service or proprietary app.

The magic is a custom MicroPython firmware compiled against Espressif IDF 4.4, which adds a camera module that the standard MicroPython builds lack. Five short Python scripts (help, html, site, webcam, wifi) then implement the HTTP server and camera control. Because everything runs in MicroPython, you can read and edit the server logic directly — no C toolchain required after the initial flash.

What You Need

Hardware

Software

Download the firmware binary and all five script files from the GitHub repository before you start.

Typical use cases

DIY Security Camera

Mount the ESP32-CAM at an entry point and access the live stream from any browser on your home network without any cloud subscription.

Timelapse Photography

Use the built-in /foto endpoint with a simple bash loop and ffmpeg to produce timelapse videos of plants, weather, or construction sites.

Robot Vision

Attach the board to a rover or pan-tilt mount and use the camera microservices as a lightweight vision feed you can extend with Python.

MicroPython Camera Experiments

The exposed camera module makes it easy to experiment with image capture, frame analysis, and custom HTTP endpoints — all in plain Python.

How It Works

The custom firmware exposes a camera module in the MicroPython runtime. After boot, webcam.py initialises the camera, connects to WiFi using credentials from wifi.py, and starts a plain HTTP server on port 80.

The server follows a simple microservices pattern — each URL path maps to a camera action:

URL path Action
/login/<password> Authenticate and lock server to your IP
/snap Capture and display a still photo
/webcam Start MJPEG live stream in browser
/rot/<degrees> Rotate the image
/foto Return a JPEG for scripted download
/live Stream video to a file via curl
/logout Release IP lock and generate new password

Authentication is IP-based with a random password printed to the REPL. A single client is allowed at a time; other IPs are blocked until logout. You can disable auth entirely by setting auth.on = False in webcam.py.

Flash the Firmware and Upload Scripts

Step 1 — Wire for flashing

Bridge GPIO-00 to GND with a jumper wire. Connect the FTDI adapter to the ESP32-CAM board, crossing TX↔RX. Plug the FTDI adapter into your PC.

Step 2 — Flash with Thonny

  1. Open Thonny and go to Tools → Options → Interpreter.
  2. Choose MicroPython (ESP32) and set Port to Try to detect port automatically.
  3. Click Install or update firmware, select your port (e.g. /dev/ttyUSB0), browse to firmware.bin, and click Install.
  4. When done, remove the GPIO-00 jumper and press the RST button.

You should see a MicroPython REPL in the Thonny shell:

MicroPython v1.18-610-gcf7d962cf-kaki5 on 2022-06-10; ESP32 CAMERA module (KAKI5) with ESP32
>>>

Step 3 — Test the camera

>>> import camera
>>> camera.init()
True
>>> img = camera.capture()
>>> len(img)
58810

Step 4 — Edit WiFi credentials

Open wifi.py in Thonny and replace YOUR-SSID and YOUR-PWD with your network details.

Step 5 — Upload all five scripts

For each of help.py, html.py, site.py, webcam.py, and wifi.py: open the file in Thonny, then go to File → Save as… and choose MicroPython device as the destination. Verify with:

>>> uos.listdir()
['boot.py', 'help.py', 'html.py', 'site.py', 'webcam.py', 'wifi.py']

Step 6 — Start the server

>>> execfile('webcam.py')
Camera ready?:  True
Connected to your-network
network config: ('10.0.0.46', ...)
PWD: M1XDYKh3
Try - http://10.0.0.46/login/M1XDYKh3

Open the login URL in a browser, then navigate to the root IP for the help page.

Timelapse and Video Recording

Because the server exposes plain HTTP endpoints, standard Linux tools work perfectly for automation.

Timelapse — capture a frame every 30 seconds:

#!/bin/bash
cnt=0
while :
do
  let "cnt=cnt+1"
  N=$( printf '%04d' $cnt )
  curl http://10.0.0.46/foto --output foto$N.jpeg
  sleep 30
done

Compile frames into a video with ffmpeg:

cat foto*.jpeg | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -i - -vcodec libx264 tmlap.mp4

Record a live stream directly to a file:

curl http://10.0.0.46/live --output live.avi
# Press Ctrl+C to stop

Play back with any video player, such as celluloid.

Ideas to Extend and Known Limits

Ideas

Limitations

Verdict

This project is a clean, practical starting point for anyone who wants camera-enabled MicroPython on an ESP32-CAM without wrestling with a C build environment. The five-script server is readable and hackable, making it a solid base for security cameras, timelapse rigs, or robot vision feeds. The main barrier is the FTDI adapter requirement and single-client limitation, but neither is a dealbreaker for a personal or maker project.

Sources

github.comshariltumin/esp32-cam-micropython-2022 — repository & README

Facts 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.