It might be a while, but I have a similar request. In my case, I made the esp32cam wake up every 10 minutes for 20 seconds. There’s an automation in HA that runs every 14 seconds and tries to download the picture.
Ideally, HA would know when to take the picture, I think it might be possible to do that. A better case would be if esp32cam can upload the file directly somewhere.
Battery consumption is somewhat decent, can be improved with longer sleep times - 150-240 mA while active, 3-5mA while sleeping. I’m keeping a backup of the old photo while getting the new one. Anyway, this is as far as I’ve gotten, for now.
ESPHome code:
esphome:
name: esp32cam1
platform: ESP32
board: esp-wrover-kit
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
reboot_timeout: 60s
use_address: esp32cam1.local
manual_ip:
static_ip: <your ip here>
gateway: !secret gateway
subnet: !secret subnet
ap:
ssid: esp32cam1
password: "********"
captive_portal:
# Example configuration entry
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
# Image settings
name: ESP32 Cam 1
# ...
resolution: 640x480
jpeg_quality: 10
max_framerate: 1 fps
idle_framerate: 0.01 fps
switch:
- platform: restart
name: Restart device
light:
- platform: monochromatic
output: led
name: "LED"
output:
- platform: ledc
id: led
pin: GPIO4
frequency: "1000Hz"
sensor:
- platform: wifi_signal
name: WiFi signal
- platform: uptime
name: Uptime Sensor
time:
- platform: homeassistant
id: homeassistant_time
# Enable logging
logger:
level: VERBOSE
# Enable Home Assistant API
api:
ota:
deep_sleep:
run_duration: 15s
sleep_duration: 600s
esp32_camera_web_server:
- port: 8080
mode: stream
- port: 8081
mode: snapshot
In configuration.yaml for HA:
shell_command:
snapshot_esp32cam1: cp ./www/esp32cam1.jpg ./www/esp32cam1_old.jpg && curl --max-time 10 http://<your IP here>:8081/ -o ./www/esp32cam1.jpg -s
Automation:
alias: esp32cam1 snapshot
description: ""
trigger:
- platform: time_pattern
hours: "*"
minutes: "*"
seconds: /14
condition: []
action:
- service: shell_command.snapshot_esp32cam1
data: {}
mode: single