How to flash an ESP32 CAM using ESPhome Dashboard and integrate it in Home Assistant.

Connect the ESP32 CAM device to the computer using a USB to serial converter.

| ESP32 Pin | Serial Adapter Pin |
| 5V* | VCC |
| GND | GND |
| UOR | TX |
| UOT | RX |
| GND -> IO0** |
**:the connection is needed to put the device in flash mode. Power cycle OFF-ON to start.
Run ESPhome Dashboard by running the following script “start_esphome_dashboard.sh” (Note: need to install docker and download esphome container):
#!/bin/bash -e
# this script to start the ESPHOME Dashboard using docker.
sudo docker run --rm -p 6052:6052 -e ESPHOME_DASHBOARD_USE_PING=true -v "${PWD}":/config -it esphome/esphome
exit
The ESPhome Dashboard is accessible at url 0.0.0.0:6052

A typical configuration file (yaml) for ESP32 Cam can be found below:
substitutions:
name: "esp32-cam"
friendly_name: "ESP32-Cam"
esphome:
name: ${name}
friendly_name: ${friendly_name}
esp32:
board: esp32dev
framework:
type: arduino
wifi:
ssid: "Sotong_Purnama"
password: "15sotong15"
manual_ip:
static_ip: 192.168.86.25
gateway: 192.168.86.1
subnet: 255.255.255.0
dns1: 192.168.86.1
dns2: 8.8.8.8
# Enable logging
logger:
web_server:
port: 80
sensor:
- platform: uptime
id: sensor_uptime
- platform: template
id: sensor_uptime_timestamp
name: ${friendly_name} Uptime
device_class: "timestamp"
accuracy_decimals: 0
update_interval: never
lambda: |-
static float timestamp = (
id(time_homeassistant).utcnow().timestamp - id(sensor_uptime).state
);
return timestamp;
- platform: wifi_signal
name: ${friendly_name} Signal
update_interval: 60s
# to fix the fact that there is an ESP_FAIL return
external_components:
- source:
type: git
url: https://github.com/MichaKersloot/esphome_custom_components
components: [ esp32_camera ]
# After addition of the above block, the camera works well
time:
- platform: homeassistant
id: time_homeassistant
on_time_sync:
- component.update: sensor_uptime_timestamp
captive_portal:
ota:
password: "15sotong15"
# Enable Home Assistant API
api:
encryption:
key: "pOvaU0RjFfCahr2K84IWhrEAiDgTuMRQLwEpntgZHsE="
esp32_camera:
id: espcam
# name: esp-cam
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
# resolution: 800x600
jpeg_quality: 10 # max. 63
max_framerate: 20.0fps
# idle_framerate: 0.2fps
vertical_flip: false
# horizontal_mirror: false
# brightness: 2 # -2 to 2
# contrast: 1 # -2 to 2
# special_effect: none
# exposure settings
# aec_mode: auto
# aec2: false
# ae_level: 0
# aec_value: 300
# gain settings
# agc_mode: auto
# agc_gain_ceiling: 2x
# agc_value: 0
# white balance setting
# wb_mode: auto
# Image settings
name: Esp32-Cam
output:
# white LED
- platform: ledc
channel: 2
pin: GPIO4
id: espCamLED
# red status light
- platform: gpio
pin:
number: GPIO33
inverted: True
id: gpio_33
light:
- platform: monochromatic
output: espCamLED
name: esp-cam light
- platform: binary
output: gpio_33
name: esp-cam led
switch:
- platform: restart
name: esp-cam restart
binary_sensor:
- platform: status
name: esp-cam status
# motion sensor connected on GPIO2
- platform: gpio
pin: 2
name: "PIR Sensor"
device_class: motion
Once the code seems ok, SAVE the yaml file (top right corner) and INSTALL (top right corner).


For the 1st installation, try the 2nd option. If it does not work, try the 4th option using the Legacy pattern.
For successive installations (updates), use the Wireless option.
Flash the binary using ESP Flasher. Binary can be found in th Downloads folder of the computer running ESPhome Dashboard.
