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

main topic shortcuts > intro 1 > intro 2 > step 1 > step 2 > step3a > step 3b > step 4

ESPhome is software that can program (or flash) an ESP chip. This chip is at the core of many automation projects. The software works 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. Other examples:

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 and whether someone is going to press the doorbell in this doorbell project. You’ll find a cookbook with a few 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

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, 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.

Leave a Reply

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