1Setup, gather components
For programming you will need a suitable development environment, I use the Arduino IDE, but this code should work in the Espressif development environment too.
Follow This Guide to set up the Espressif Arduino core in the IDE.
The AI-THINKER board requires use of an external 3.3v serial adapter to program; I use a
FTDI Friendadapter, for more about this read AdaFruits excellent FTDI Friend guide.
Be careful not to use a 5v serial adapter since this will damage the ESP32.
Hooking this up is pretty simple, see the diagram below.
Connect the RX line from the serial adapter to the TX pin on ESP32
The adapters TX line goes to the ESP32 RX pin
The GPIO0 pin of the ESP32 must be held LOW (to ground) when the unit is powered up to allow it to enter it's programming mode. This can be done with simple jumper cable connected at poweron, fitting a switch for this is useful if you will be reprogramming a lot.
You must supply 5v to the ESP32 in order to power it during programming, the FTDI board can supply this.
Download the code from the Files section here, or clone the GitHub repo.
You need to set the Board you are using in the main
esp32-cam-webserver.inosketch file, it defaults to the AI-THINKER, but the WRover Kit, ESP Eye and M5Stack are also availiable.
You can also set the camera name plus SSID and password for your WiFi network in that file, or follow the notes about using a separate file for your settings.
Assuming you are using the latest Espressif Arduino core the AI-THINKER board will appear in the ESP32 Arduino section of the boards list.
Compile and upload the code from the IDE, when the
Connecting...appears in the console reboot the ESP32 module while keeping GPIO0 grounded. You can release GPIO0 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.
If you have a status LED configured it will give a single slow flash when it begins attempting to conenct to WiFi, and three 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!