flash a ESP32-CAM to make a smart camera (esphome 3a)

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.

   devicename: cat_camera
   name: ${devicename}
   platform: ESP32
   board: esp32dev
#Enable logging

# Enable a connection to the Home Assistant API 
  password: "YOUR Home ASSISTANT API password"
  password: ""

   ssid: "YOUR_SSID"
   password: "YOUR WIFI PASSWORD"
     # Set this to the IP you want for the ESP
     # Set this to the IP address of the router. Often ends with .1
     # The subnet of the network. works for most homes 
#Author by airijia.com board: esp32dev
     pin: GPIO0
     frequency: 20MHz
     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
   - platform: gpio
     pin: GPIO4
     id: gpio_4 

  - platform: binary
    output: gpio_4
    name: ${devicename} light  

# The following can be omitted 
  - platform: restart
    name: ${devicename} restart 

  - 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

On the right is a 3.3v ftdi which connects to the computer. On the left are dupont leads to connect to the ESP32-CAM.
  1. Identify the VCC (or 3.3v input), GND, TX and RX on the ESP32-CAM
  2. Use female-to-female Dupont jumper leads to connect the ESP32-CAM to a FTDI UART board set at 3.3v.
  3. Add the code to the ESPhome ‘node’. Validate and compile the code into a binary file on your PC.
  4. 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.
  5. Use Esphome-flasher to upload the binary file to the ESP32-CAM.
A groundbreaking moment for one maker – my thanks to them for breaking ground for me.

2 Responses

  1. Graeme Watt says:

    Compiling failed on the first word of the first line of the example code; Substititions.

    • roger says:

      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.

Leave a Reply

Your email address will not be published. Required fields are marked *