ESP32-CAM as doorbell with camera Topic is solved

Moderator: leecollings

Post Reply
stack
Posts: 36
Joined: Friday 17 July 2020 15:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11794
Contact:

Re: ESP32-CAM as doorbell with camera

Post by stack »

Looks good.
joostnl
Posts: 68
Joined: Wednesday 03 February 2016 19:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: ESP32-CAM as doorbell with camera

Post by joostnl »

Looking great! Upload your files if you have time i can help you improve it.
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by hoeby »

I am a little stuck with adding the wifi-manager.

Enough examples for esp8266 environment, but those are not working on an esp32. This is one which first needs to work.
As a start inhave taken the esp32camera example out the ode program.
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by jvdz »

I can have a look when you can share the current project. I've converted an esp8266 project using telegram/webserver and wifimanager to an esp32 and got that working. You do have to use the wifimanager development branch for esp32.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by hoeby »

Could you say which branch you used?
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by jvdz »

The project I converted was a local private esp program I use, hence the request for your source as I don't have anything yet for this project. ;)
I have no ESP with camera to test, but can at least check whether I am able to convert and compile it for esp32 and load it on an ESP32 without cam.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by hoeby »

This is what i have for now.
It is only the wifi-manager. I first want that to work and then build further.

This wifi-manager works.
It starts an AP with the name ESP-32-CAM (pass: 12345678)
I can choose a wifi-ssid and connect. All that works.

Now i have to extend the code, that it looks if there is a saved config. That it will not restart the wifi-manager.
When a ssid if configured, then it restart. After the restart it again start the wifi-manager. But it has not to do that, otherwise this unsecure AP stays open. It is unsecure, because the default password is online.

Code: Select all


#include <WiFi.h>       
#include <WebServer.h>     // https://github.com/zhouhan0126/WebServer-esp32  

#include <DNSServer.h>     // https://github.com/zhouhan0126/DNSServer---esp32  
#include <WiFiManager.h>   // https://github.com/zhouhan0126/WIFIMANAGER-ESP32


void setup() {
  Serial.begin(115200);

  WiFiManager wifiManager;

// wifiManager.setAPCallback(configModeCallback); 
// wifiManager.setSaveConfigCallback(saveConfigCallback); 
 
  wifiManager.autoConnect("ESP_32_CAM", "12345678"); 

  if(!wifiManager.startConfigPortal("ESP_32_CAM", "12345678") ){
       Serial.println("Failed, going to restart");
        delay(2000);
        ESP.restart();
        delay(1000);
      }
      Serial.println("Connect to ESP_32_CAM");
}

void loop() {
    
   }
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by jvdz »

You basically start the portal after you successfully connected to the WiFi with this line:

Code: Select all

if(!wifiManager.startConfigPortal("ESP_32_CAM", "12345678") ){
Just look at the examples you find it the library, but basic operation is to simply remove that if block.

Code: Select all

void setup()
{
    Serial.begin(115200);
    WiFiManager wifiManager;
    wifiManager.autoConnect("ESP_32_CAM", "12345678");
    Serial.println("Connected to WiFi");
}

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by hoeby »

Changed the code to this.
It looks to work. Is this a good way to program this kind of feature?

Next on the road: Find a way that the IP-address, when connected to the SSID, is projected on a page. So you know to which IP to connect.

Code: Select all

#include <WiFi.h>       
#include <WebServer.h>     // https://github.com/zhouhan0126/WebServer-esp32  

#include <DNSServer.h>     // https://github.com/zhouhan0126/DNSServer---esp32  
#include <WiFiManager.h>   // https://github.com/zhouhan0126/WIFIMANAGER-ESP32


void setup() {
  Serial.begin(115200);

  WiFiManager wifiManager;

// wifiManager.setAPCallback(configModeCallback); 
// wifiManager.setSaveConfigCallback(saveConfigCallback); 
 
  wifiManager.autoConnect("ESP_32_CAM", "12345678"); 

  if (WiFi.SSID() =="") {
    if(!wifiManager.startConfigPortal("ESP_32_CAM", "12345678") ){
       Serial.println("Failed, going to restart");
       delay(2000);
       ESP.restart();
       delay(1000);
    } else {
       Serial.println("Connect to SSID");
    }
  }

  if (WiFi.status()!=WL_CONNECTED){
    Serial.println("failed to connect, finishing setup anyway");
  } else{
    Serial.print("local ip: ");
    Serial.println(WiFi.localIP());
  }
}

void loop() {
    
   }
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by jvdz »

Not sure why you have coded it that way with the 2 if's. They do not really serve a purpose, but guess it should work.
To get the IP address is easy: "WiFi.localIP().toString()" returns a String with the IP address. 8-)

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by hoeby »

The double if:
The idea is to use it because if (WiFi.SSID() =="") closes not all posibilities.
example, you connect to wifi-ssid-1, but your home network changes to wifi-ssid-2.
Then the extra if could start the portal again, so you can access it. Otherwise you never can access again, without modifying the code.
Of course it is on the wishlist, that there will be a html page, where you could remove it, but this is just in case
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by jvdz »

The portal will always start when it is unable to connect to the saved SID, so that logic isn't needed as far as I know.
Just give it a try and you will see.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by hoeby »

It looks like this line "WiFi.localIP().toString()" isn't going to work.
When testing the portal opens and starts the AP on the ESP. Then there is a wifi setup done and after that the AP is closed and it connects to its wifi.
Then the connetion to 192.168.4.1 is already lost when i want to do the "WiFi.localIP().toString()"

To get that working, it needs to be added in the library.
Is my thinking right?

Also strange, i don't see these Serial lines in the monitor. It stays at a serial which starts with a (WM). Looks like the serial from the wifimanager.

Code: Select all

 if (WiFi.status()!=WL_CONNECTED){
    Serial.println("failed to connect, finishing setup anyway");
  } else{
    Serial.print("local ip: ");
    Serial.println(WiFi.localIP());
    }
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by jvdz »

No sure I understand what you mean... this seems to work fine:

Code: Select all

#include <WiFi.h>       
#include <WebServer.h>     // https://github.com/zhouhan0126/WebServer-esp32  
#include <DNSServer.h>     // https://github.com/zhouhan0126/DNSServer---esp32  
#include <WiFiManager.h>   // https://github.com/zhouhan0126/WIFIMANAGER-ESP32

void setup()
{
  Serial.begin(115200);
  delay(1000);
  WiFiManager wifiManager;

  wifiManager.autoConnect("ESP_32_CAM", "12345678");
  Serial.println("Connected to Wifi");
  Serial.print("local ip: ");
  Serial.println(WiFi.localIP());
}

void loop()
{
  Serial.print("local ip: ");
  Serial.println(WiFi.localIP());
  delay(1000);
}
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by hoeby »

Started on V2, but also stopped with it.
This goes out of my head to get those things working.

Got the camera working, but then i don't get it to work to build an active webpage for your settings.
When i start with an active wegpage for the settings, then the camera isn't working.
The wifimanager was the first thing i dropped in the bin, didn't got it to work that i get full control back.

I parked it. Maybe something in the future, but for now i will keep the code i changed a few pages back.
i am not a programmer and need to everything with google. this is going to take to much time i don't want to spend to it.

ps.
can't share the code i had for V2. Tried that many things, that the code isn't working anymore at all
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
stack
Posts: 36
Joined: Friday 17 July 2020 15:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11794
Contact:

Re: ESP32-CAM as doorbell with camera

Post by stack »

Anyway thanks for your time in this project, been running v1 for a while and very happy. We may see an update in the future.
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by hoeby »

stack wrote: Saturday 01 August 2020 8:55 want to use motioneye for motion detection
Could you tell me what you do with the motion detection?

Does it send a message, flips a switch or triggers a script?
Would love to know, where you use this function for.
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
stack
Posts: 36
Joined: Friday 17 July 2020 15:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11794
Contact:

Re: ESP32-CAM as doorbell with camera

Post by stack »

motion detection is an addition to this doorbell.
This goes via motioneye and it gives a telegram message with a screenshot when there is movement.
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: ESP32-CAM as doorbell with camera

Post by hoeby »

Is that the only reason you have it on motioneye, to do the motion detection?
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
stack
Posts: 36
Joined: Friday 17 July 2020 15:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11794
Contact:

Re: ESP32-CAM as doorbell with camera

Post by stack »

hoeby wrote: Friday 11 September 2020 17:32 Is that the only reason you have it on motioneye, to do the motion detection?
yes for now
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests