ESP32 CAM How to Take a JPG with Flash ON

Hi,

I have a ESP32 Cam working to just stream video, I want to be able to Trigger from an automation to do the following:

Turn onboard Flash Light ON
Take a still JPG and display in Lovelace
Turn onboard Flash Light OFF

Can anyone give me pointers where to start with this?
Below is my ESPHOME code


#################################################################
#                                                               #
#                           CAMERA                              #
#                                                               #
#################################################################


esphome:
  name: camtest1
  platform: ESP32
  board: esp-wrover-kit

wifi:
  ssid: ######
  password: #####
  manual_ip:
    static_ip: 192.168.1.100
    gateway: 192.168.1.1
    subnet: 255.255.255.0


# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

esp32_camera:
  name: My 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
  


output:
#flashlight
#  - platform: gpio
#    pin: GPIO4
#    id: gpio_4
#statuslight
  - platform: gpio
    pin:
      number: GPIO33
      inverted: True
    id: gpio_33

    
sensor:
  - platform: wifi_signal
    name: $hostname WiFi Signal
    update_interval: 60s
  - platform: uptime
    name: $hostname Uptime

    
text_sensor:
  - platform: version
    name: $hostname ESPHome Version
  - platform: wifi_info
    ssid:
      name: $hostname WiFi

switch:      
  - platform: restart
    name: $hostname restart


From what I have read I need to add the following to esphome esp32cam yaml:

output:
  - platform: gpio
    pin: GPIO4
    id: gpio_4 

light:
  - platform: binary
    output: gpio_4
    name: flashlight 

But when I do this I get an error
light.gpio platform not found…?

Any help appreciated…

I have found if I change this

light:
  - platform: binary
    output: gpio_4
    name: flashlight 

to this it works, I can turn the flash On & OFF

switch:        
  - platform: gpio
    name: "Flashlight"
    pin: GPIO4

Now just to find out how to take a still and display

1 Like

Hey,

I followed your intrusions and added “Light” to my esp32.yaml and a switch for the light showed up in HA.
I didn’t need to change “Light” to “switch”.