A professional firmware implementation for ESP32-CAM that provides ONVIF compatibility, RTSP streaming, and a web-based configuration interface with WiFi network scanning capabilities.
- ONVIF Protocol Support: Enables integration with NVR/DVR systems and surveillance software
- RTSP MJPEG Streaming: Stream video on port 554
- WiFi Network Scanning: Scan for available networks and connect without hardcoding credentials
- Web Configuration Interface: Configure camera settings through a browser
- SD Card Recording: Save video recordings directly to microSD card
- Motion Detection: Basic motion detection capability
- Credential Storage: Securely store WiFi credentials in SPIFFS
- Access Point Fallback: Automatically creates an AP if unable to connect to WiFi
- ESP32-CAM board (AI-Thinker or compatible)
- MicroSD card (optional, for recording)
- 5V power supply
- FTDI programmer/adapter (for initial flashing)
- Arduino IDE
- ESP32 Arduino Core
- Required Libraries:
- ArduinoJson
- ESP32 Camera Driver
- SPIFFS file system
-
Install Arduino IDE from arduino.cc
-
Add ESP32 board support:
- Go to File > Preferences
- Add
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.jsonto the "Additional Board Manager URLs" field - Go to Tools > Board > Boards Manager
- Search for "ESP32" and install the latest version
-
Install required libraries:
- Go to Tools > Manage Libraries
- Search for and install "ArduinoJson"
-
Connect the ESP32-CAM to your computer using an FTDI adapter:
- FTDI GND -> ESP32-CAM GND
- FTDI 5V/3.3V -> ESP32-CAM 5V
- FTDI TX -> ESP32-CAM RX
- FTDI RX -> ESP32-CAM TX
- Connect GPIO0 to GND (puts ESP32-CAM in flash mode)
-
Select the correct board and port:
- Tools > Board > ESP32 Arduino > AI-Thinker ESP32-CAM
- Tools > Port > [Select your FTDI port]
-
Upload the firmware:
- Click the Upload button or use Sketch > Upload
- After uploading, disconnect GPIO0 from GND and reset the ESP32-CAM
-
Install Visual Studio Code from code.visualstudio.com
-
Install the PlatformIO extension:
- Open VS Code
- Go to Extensions (or press Ctrl+Shift+X)
- Search for "PlatformIO IDE"
- Click Install
-
Create a new project:
- Click the PlatformIO icon in the sidebar
- Select "New Project"
- Enter a project name (e.g., "ESP32-CAM-ONVIF")
- Select "AI Thinker ESP32-CAM" as the board
- Select "Arduino" as the framework
- Choose a location for your project
- Click "Finish"
-
Configure your project:
- Open the
platformio.inifile in the project root - Add the following configuration:
- Open the
[env:esp32cam]
platform = espressif32
board = esp32cam
framework = arduino
monitor_speed = 115200
lib_deps =
bblanchon/ArduinoJson @ ^6.21.3
# Add other dependencies as needed
upload_speed = 921600
build_flags =
-DCORE_DEBUG_LEVEL=5- Import the project files:
- Copy all files from the ESP32-CAM+ONVIF repository to the
srcdirectory of your PlatformIO project - Copy the files from the
datadirectory to thedatadirectory in your PlatformIO project
- Copy all files from the ESP32-CAM+ONVIF repository to the
- Connect your ESP32-CAM as described in the Arduino section (with GPIO0 connected to GND)
- Click the PlatformIO upload button or run the Upload task
- To upload the SPIFFS data (web interface files):
- Click on the PlatformIO tasks menu
- Select "Upload File System image"
- Disconnect GPIO0 from GND and reset the ESP32-CAM
- On first boot, the ESP32-CAM will create an access point named "ESP32-CAM+ONVIF"
- Connect to this access point with password "esp32cam"
- Open a web browser and navigate to
http://192.168.4.1 - Log in with the default credentials:
- Username:
admin - Password:
esp123
- Username:
- Once logged in, click on the "WiFi" tab
- Click "Scan Networks" to see available WiFi networks
- Select your network from the list
- Enter your WiFi password when prompted
- The ESP32-CAM will connect to your network and restart
- After restart, access the camera using its new IP address on your network
- Access the web interface by entering the ESP32-CAM's IP address in a browser
- The interface provides tabs for:
- Live: View the live camera stream
- Camera: Adjust camera settings (resolution, quality, etc.)
- WiFi: Configure WiFi connections
- SD Card: Manage recordings on the SD card
- System: View system information and reboot/reset options
The camera provides ONVIF and RTSP services:
- ONVIF discovery service on port 8000
- RTSP stream available at
rtsp://[camera-ip]:554/mjpeg/1
Add the camera to your NVR/DVR system using these details.
ESP32-CAM+ONVIF.ino: Main sketch filecamera_control.cpp/.h: Camera initialization functionsrtsp_server.cpp/.h: RTSP streaming implementationonvif_server.cpp/.h: ONVIF protocol implementationweb_config.cpp/.h: Web interface implementationwifi_manager.cpp/.h: WiFi scanning and connection managementsd_recorder.cpp/.h: SD card recording functionalitymotion_detection.cpp/.h: Motion detection implementationdata/: Web interface files (HTML, CSS, JavaScript)
This project is licensed under the MIT License. See the LICENSE file for details.
- Original implementation by J0X
- WiFi scanning functionality added by BitVentures USA
- Thanks to the ESP32, Arduino, and PlatformIO communities
Contributions to improve the firmware are welcome. Please feel free to submit a pull request or open an issue to discuss proposed changes.
