Send picture from ESP32CAM to HA

Hi,
I am searching for options how to make low power camera with low refresh rate (say 1-10 minutes).

The idea would be, to take ESP32cam, wake it up periodically and send and overwrite image.jpg to HA file system. In HA, I can just show a picture card with latest picture. I believe that this would be the best solution, so HA don’t need to poll when ESP32cam is woken up (thus camera can be awake for shorter time).

I did not find any good ways how to accomplish this. The closest to low power is option D (below), but I think there should be more elegant and low power way to do this.

Thanks for your help!

The ideas I explored:

  • A: using esp-home and camera stream in HA like in this post. The solution is not that much low power, because 20 seconds on-time is quite a lot. It can be improved with triggering the snapshot on availability of esp32cam device but not ideal.
  • B: using HTTP POST with PHP to send image with this code. Here I have no clue how would I make PHP server in HA.
  • C: using FTP with this code is ESP32cam. Again, making simple FTP in HA is not easy. There is this HACS extension, but it seems it needs SSL, what is not in ESP32 code I think.
  • D: Using web server code in ESP32cam (like this one) where I can add sleep and reading new custom HA entity “cam_status” via HA API or MQTT. Automation in HA would be triggered on ESP32cam availability, action is to get snapshot and set “cam_status” to “go_sleep” which camera reads and shuts down.

I think one easy option would be to install an nginx server in a Docker container. That server should be configured to allow upload to the ./www folder, wherever this is stored (e.g. /usr/share/hassio/homeassistant/www). The ESP can wake up and upload to this location.

The other option is that the ESP triggers some action on wake-up, which triggers the script to download. HA then sends back a message which causes the ESP to shut down. You need to time how long it takes, but it will be longer than the option above, so higher power consumption.

Still, either way, with a 10 minute period, the power usage should be quite low. Assuming 5 seconds wake-up time, 200mA, that’s 0.28 mAh per wake-up, 67mAh per day. Not sure about the idle consumption, but let’s say another 67mAh per day. So 18 days with a 2500mAh battery.

1 Like