flash a ESP32-CAM to make a smart camera (esphome 3a)
main topic shortcuts > intro a > intro b > step 1 > step 2 > step3a > step 3b > step 4
ESPhome is software that can add a program to (or “flash firmware to”) an ESP chip. This chip is at the core of many automation projects. The software connects things up inside Home Assistant running on a Raspberry Pi. The instructions below show how to make the firmware (a file) that gets an ESP32-CAM camera connected to Home Assistant. (IF YOU PREFER to have an independant standalone web camera see this project here)
I use an ESP32 to monitor how much heating oil is in my tank – see the oil level project; how much electricity I’m using through the day in a meter reader project. I’m working on a way to know when someone is going to press the doorbell. You’ll find a cookbook with more projects at ESPhome

compile the ESPhome code into firmware
What we’re trying to do is to add our code to the ESP chip and replace what’s currently there. We first copy and paste this code into the ESPhome interface and add our wifi password and network settings. We can also add a wifi signal meter. We can re-edit this code for future projects.
# ITEMS IN BOLD NEED EDITING substitutions: devicename: cat_camera esphome: name: ${devicename} platform: ESP32 board: esp32dev #Enable logging logger: # Enable a connection to the Home Assistant API api: password: "YOUR Home ASSISTANT API password" ota: password: "" wifi: ssid: "YOUR_SSID" password: "YOUR WIFI PASSWORD" manual_ip: # Set this to the IP you want for the ESP static_ip: 192.168.1.171 # Set this to the IP address of the router. Often ends with .1 gateway: 192.168.1.1 # The subnet of the network. 255.255.255.0 works for most homes #Author by airijia.com board: esp32dev esp32_camera: external_clock: pin: GPIO0 frequency: 20MHz i2c_pins: sda: GPIO26 scl: GPIO27 data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35] vsync_pin: GPIO25 href_pin: GPIO23 pixel_clock_pin: GPIO22 power_down_pin: GPIO32 name: ${devicename} cam resolution: 800x600 # Flashlight CHECK PIN output: - platform: gpio pin: GPIO4 id: gpio_4 light: - platform: binary output: gpio_4 name: ${devicename} light # The following can be omitted - platform: restart name: ${devicename} restart sensor: - platform: wifi_signal name: ${devicename} wifi signal update_interval: 600s - platform: uptime name: ${devicename} uptime
How to ‘flash’ or put this code into a ESP32-CAM – words and video

- Identify the VCC (or 3.3v input), GND, TX and RX on the ESP32-CAM
- Use female-to-female Dupont jumper leads to connect the ESP32-CAM to a FTDI UART board set at 3.3v.
- Add the code to the ESPhome ‘node’. Validate and compile the code into a binary file on your PC.
- Connect GPIO0 to GND with a Dupont lead as you plug the FTDI into a USB socket on your computer. You might also need to press the button on the ESP32-CAM.
- Use Esphome-flasher to upload the binary file to the ESP32-CAM.
Compiling failed on the first word of the first line of the example code; Substititions.
Tardy reply from me: by now I hope you’ll have noticed that the compiler isn’t helpful at locating a problem – it gets thrown by as little as a wrong space or colon. It’s not the “substitutions:” bit, it’s further below.
A possible problem is that any of the sections further down your code is incomplete or incorrect.