- 📷 MJPEG Streaming over WiFi (port 81)
- 💾 Auto-capture to microSD (every 5 seconds, configurable)
- 🌐 Web Interface for viewing and control (port 80)
- 📡 REST API:
/status,/capture
esp32cam_project/
├── CMakeLists.txt
├── partitions.csv
├── sdkconfig.defaults
└── main/
├── CMakeLists.txt
├── config.h ← ALL settings here
├── main.c
├── camera.c / .h
├── sdcard.c / .h
├── wifi.c / .h
├── http_server.c / .h
└── stream_server.c / .h
- ESP-IDF v5.x (recommended 5.2+)
- Board: AI-Thinker ESP32-CAM + Type-C downloader
#define WIFI_SSID "YOUR_SSID"
#define WIFI_PASSWORD "YOUR_PASSWORD"Add idf_component.yml to project root:
dependencies:
espressif/esp32-camera: "^2.0.0"Or clone manually:
git clone https://github.com/espressif/esp32-camera components/esp32-camera# Setup IDF
. $IDF_PATH/export.sh
# Set target
idf.py set-target esp32
# (Optional) Configuration
idf.py menuconfig
# Build
idf.py build
# Flash (replace /dev/ttyUSB0 with your port)
idf.py -p /dev/ttyUSB0 flash monitorOn the Type-C downloader board: press and hold BOOT, press RST, release BOOT.
| SD Pin | ESP32-CAM GPIO |
|---|---|
| MOSI | GPIO 15 |
| MISO | GPIO 2 |
| CLK | GPIO 14 |
| CS | GPIO 13 |
| VCC | 3.3V |
| GND | GND |
⚠️ GPIO2 is used as MISO for SD and as LED on the board — do not enable LED during SD operation.
| URL | Method | Description |
|---|---|---|
http://<IP>/ |
GET | Web player |
http://<IP>/status |
GET | JSON status |
http://<IP>/capture |
POST | Capture → SD |
http://<IP>:81/stream |
GET | MJPEG stream |
http://<IP>:81/capture |
GET | Single JPEG |
#define CAPTURE_INTERVAL_MS 5000 // auto-capture interval
#define JPEG_QUALITY 12 // 0=best, 63=worst
#define FRAME_SIZE FRAMESIZE_VGA // VGA=640×480, SVGA=800×600
#define HTTP_SERVER_PORT 80
#define STREAM_SERVER_PORT 81Media → Open Network Stream → http://<IP>:81/stream
import cv2
cap = cv2.VideoCapture("http://<IP>:81/stream")
while True:
ret, frame = cap.read()
if ret:
cv2.imshow("ESP32-CAM", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break| Symptom | Solution |
|---|---|
| Camera init failed | Check 5V power, not 3.3V |
| SD mount failed | Format card as FAT32 |
| WiFi not connecting | Verify SSID/password, 2.4GHz only |
| Stream freezing | Lower resolution or increase quality |
| PSRAM error | Ensure CONFIG_ESP32_SPIRAM_SUPPORT=y |