ESP32 WebCam Server 5.0
Fully customizable WebCam server based on Espressif ESP32-based board with a camera.
|
This sketch is a fully customizable webcam server based on ESP32-based board with camera. It can be used as a starting point for your own webcam solution.
There are many other variants of a webcam server for these modules online, but most are created for a specific scenario and not good for general, casual, webcam use.
Hopefully this expanded example is more useful for those users who wish to set up a simple ESP32 based webcam using the cheap(ish) modules freely available online.
When re-desiginig and refactoring the original ESP32 Camera web server example from Espressve, the following key principles were followed:
Given the above, face recognition feature was removed. The main purpose of this sketch is to make the camera web server easily configurable and reusable.
The original example, is a bit incomprehensible and hard to modify as supplied. It is very focused on showing off the face recognition capabilities, and forgets the 'webcam' part.
The sketch has been tested on the AI Thinker ESP32-CAM module. Other ESP32 boards equipped with camera may be compatible but not guaranteed.
The ESP32 itself is susceptible to the usual list of WiFi problems, not helped by having small antennas, older designs, congested airwaves and demanding users. The majority of disconnects, stutters and other communication problems are simply due to 'WiFi issues'.
The AI-THINKER camera module & esp32 combination is quite susceptible to power supply problems affecting both WiFi conctivity and Video quality; short cabling and decent power supplies are your friend here; also well cooled cases and, if you have the time, decoupling capacitors on the power lines.
A basic limitation of the sketch is that it can can only support one stream at a time. If you try to connect to a cam that is already streaming (or attempting to stream, the first steam will freeze.
Currently, camera modules other than ov2640 are not supported.
Is pretty simple, You just need jumper wires, no soldering really required, see the diagram below.
Download the latest release of the sketch this repository. Once you have done that you can open the sketch in the IDE by going to the esp32-cam-webserver
sketch folder and selecting esp32-cam-webserver.ino
.
You also need to copy the content of the data folder from this repository to a micro SD flash memory card (must be formatted as FAT32) and insert it into the micro SD slot of the board.
Without the SD card, the sketch will not start. Please ensure the size of the card does not exceed 4GB, which is a maximum supported capacity for ESP32-CAM board. Higher capacity SD card may not work.
You will need to configure the web server with your WiFi settings. In order to do so, you will need to create a config file in the root folder of your SD card named conn.json
and format it as follows:
Replace the WiFi and OTA parameters with your settings and save. PLease note that the sketch will not boot properly if WiFi connection is established.
Web server name can configured by creating another config file, httpd.json
, in the root folder of the SD card:
The parameter mapping
allows to configure folders with static content for the web server.
Similarly, default camera configuration parameters can be set by creating the file cam.json
:
Assuming you are using the latest Espressif Arduino core the ESP32 Dev Module
board will appear in the ESP32 Arduino section of the boards list. Select this (do not use the AI-THINKER
entry listed in the boiards menu, it is not OTA compatible, and will cause the module to crash and reboot rather than updating if you use it.
Make sure you select the Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
partition cheme and turn PSRAM
on.
The first time you program (or if OTA is failing) you need to compile and upload the code from the IDE, and when the Connecting...
appears in the console reboot the ESP32 module while keeping GPIO0 grounded. You can release GPO0 once the sketch is uploading, most boards have a 'boot' button to trigger a reboot.
Once the upload completes (be patient, it can be a bit slow) open the serial monitor in the IDE and reboot the board again without GPIO0 grounded. In the serial monitor you should see the board start, connect to the wifi and then report the IP address it has been assigned.
Once you have the initial upload done and the board is connected to the wifi network you should see it appearing in the network ports
list of the IDE, and you can upload wirelessly.
If you have a status LED configured it will give a double flash when it begins attempting to conenct to WiFi, and five short flashes once it has succeeded. It will also flash briefly when you access the camera to change settings.
Go to the URL given in the serial output, the web UI should appear with the settings panel open. Click away!
The communications between the web browser and the camera module can also be used to send commands directly to the camera (eg to automate it, etc) and form, in effect, an API for the camera.
Contributions are welcome; please see the Contribution guidelines.