bellad17
(Bellad17)
February 15, 2024, 8:56am
1
hello, i have a esp32 cam for door bell , i would like when push button send a photo on ftp or email or … i have a linux server local
thank you
esphome:
name: doorbell
friendly_name: doorbell
esp32:
board: esp32dev
framework:
type: arduino
psram:
mode: octal
speed: 80MHz
# Enable logging
logger:
level: VERBOSE
ota:
password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
wifi:
ssid: 'xxxxxxxxxxxxx'
password: 'xxxxxxxxxxxx'
manual_ip:
static_ip: 192.168.1.230
gateway: 192.168.1.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Doorbell Fallback Hotspot"
password: "Tourneur17"
captive_portal:
web_server:
port: 80
esp32_camera:
name: espcam1
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: 1024x768
brightness: 2
esp32_camera_web_server:
- port: 8080
mode: stream
- port: 8081
mode: snapshot
switch:
- platform: gpio
name: "Relay"
pin: GPIO13
id: relay
- platform: gpio
name: "ding"
pin: GPIO15
id: ding
binary_sensor:
- platform: gpio
pin:
number: GPIO14
mode: INPUT_PULLUP
inverted: true
name: "Doorbell button"
filters:
- delayed_on: 10ms
- delayed_off: 30s
on_press:
- switch.turn_on: ding
- delay: 500ms
- switch.turn_off: ding
- switch.turn_on: relay
- delay: 0.5s
- switch.turn_off: relay
- delay: 1s
- switch.turn_on: relay
- delay: 0.5s
- switch.turn_off: relay
- delay: 30s
Idk if this is the most streamlined way but, you could just fire an automation that snaps a pic, then saves that pic in HA and then use one of the many file synchronizing add ons like Samba or Syncthing to then send that file to your linux box. Im not sure of how you would attatch it to an email directly from HA. That may be possible, I dont recall seeing that and have never looked into it either.
You know that you can get HA notifications that include camera snapshots sent directly to your phone, right?
1 Like
Apparently you can send emails… so, just make an automation that takes a snapshot when button is pressed, then attatch a copy of that photo to an outgoing email…
bellad17
(Bellad17)
February 17, 2024, 8:02am
4
I forgot to mention that I don’t have home assistant , my server is already at maximum and I don’t want to add another
bellad17
(Bellad17)
February 17, 2024, 8:05am
5
I found a code but I don’t know if it can be included and, if so, how.
/******************************************************************************
ESP32-CAM remote image access via FTP. Take pictures with ESP32 and upload it via FTP making it accessible for the outisde network.
Leonardo Bispo
July - 2019
https://github.com/ldab/ESP32_FTPClient
Distributed as-is; no warranty is given.
******************************************************************************/
#include "Arduino.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include <ESP32_FTPClient.h>
#include "octocat.h"
#define WIFI_SSID ""
#define WIFI_PASS ""
char ftp_server[] = "";
char ftp_user[] = "";
char ftp_pass[] = "";
// you can pass a FTP timeout and debbug mode on the last 2 arguments
ESP32_FTPClient ftp (ftp_server,ftp_user,ftp_pass, 5000, 2);
void setup()
{
Serial.begin( 115200 );
WiFi.begin( WIFI_SSID, WIFI_PASS );
Serial.println("Connecting Wifi...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
ftp.OpenConnection();
// Get directory content
ftp.InitFile("Type A");
String list[128];
ftp.ChangeWorkDir("/public_html/zyro/gallery_gen/");
ftp.ContentList("", list);
Serial.println("\nDirectory info: ");
for(int i = 0; i < sizeof(list); i++)
{
if(list[i].length() > 0)
Serial.println(list[i]);
else
break;
}
// Make a new directory
ftp.InitFile("Type A");
ftp.MakeDir("my_new_dir");
// Create the new file and send the image
ftp.ChangeWorkDir("my_new_dir");
ftp.InitFile("Type I");
ftp.NewFile("octocat.jpg");
ftp.WriteData( octocat_pic, sizeof(octocat_pic) );
ftp.CloseFile();
// Create the file new and write a string into it
ftp.InitFile("Type A");
ftp.NewFile("hello_world.txt");
ftp.Write("Hello World");
ftp.CloseFile();
ftp.CloseConnection();
}
void loop()
{
}
Rudd-O
(Rudd-O)
February 17, 2024, 8:30am
6
Would probably have to be prototyped first on the on_image event as a lambda, as image data is available in that event. Problem is that you cannot pause for so long in the lambdas.