Right now I’m struggling with the wake up pin configuration. But I agree only walking up when the door opened would be a lot better.
There are interrupt pins specifically for this kind of thing. If the board is sleeping and that interrupt pin changes state(Door opens) it will wake the board and do whatever automation you create and then go back to sleep. I’m not a big fan of battery powered and all that but, this is a frequent conversation in the forums and you shouldn’t have a hard time finding details on doing this.
Lol @bkbilly your use-case and approach is litterally identical to mine. What brought me here. (Gas Meter reading, photo, upload to server, sleep)
I’m working with GPT but its having issues with ESP Home YAML. A lot of guessing.
Ideally I’d like to get this working as a stand alone device that doesn’t need ESP Home or Home Assistant, uploads directly to my server for processing.
The following is where I’m at now… but the syntax to take the photo is currently where I’m stuck.
substitutions:
name: esphome-web-hash
friendly_name: Gas Meter Reader
esphome:
name: ${name}
friendly_name: ${friendly_name}
min_version: 2024.6.0
name_add_mac_suffix: false
project:
name: esphome.web
version: dev
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
# Allow provisioning Wi-Fi via serial
improv_serial:
wifi:
ssid: "SSID_HERE"
password: "PASSWORD_HERE"
# Set up a Wi-Fi access point as a fallback
ap: {}
# Enable captive portal for Wi-Fi provisioning
captive_portal:
dashboard_import:
package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
import_full_config: true
# Sets up Bluetooth LE (Only on ESP32) to allow the user to provision wifi credentials to the device.
esp32_improv:
authorizer: none
# Enable web server for local control and access
web_server:
port: 80
# Template switch to trigger the photo capture and upload script
switch:
- platform: template
name: "Take Photo and Upload"
id: photo_upload_trigger
turn_on_action:
- logger.log: "Digital trigger activated, taking a photo..."
- script.execute: take_photo_and_upload
# Camera configuration for ESP32-CAM
esp32_camera:
name: "Gas Meter Camera"
id: esp32cam_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 Quality
resolution: 800x600 # Set camera resolution, adjust as needed
jpeg_quality: 10 # Set JPEG quality (lower number means higher quality)
max_framerate: 1 fps
idle_framerate: 0.01 fps
# Include the HTTP Request component in your ESPHome configuration
http_request:
id: my_upload
timeout: 10s # Optional: Adjust the timeout as needed
useragent: "ESPHome-GasMeterReader" # Optional: Set a custom user agent
# Script to take a photo and upload it to a server using HTTP POST
script:
- id: take_photo_and_upload
then:
- component.update: esp32cam_camera
- delay: 5s
- camera.take_photo:
id: esp32cam_camera
filename: "/photo.jpg"
- delay: 10s
- http_request.post:
url: "http://your-server-endpoint/upload" # Replace with your server URL
headers:
Content-Type: "multipart/form-data"
file:
path: "/photo.jpg" # Path to the file on the ESP32
name: "file" # Field name in the form-data
- logger.log: "Photo taken and uploaded successfully."
This seems very promising, but I gave up on this approach.
I got power near the gas meter and used the AI-on-the-edge-device to get the measurement.
If the take_photo_and_upload script works for you, you should also use the deep_sleep component to conserve power.