ESP32 Cam - working!

I have a strange issue with one of my cams. When power is off for an extended period and then restored the device comes online but I get no image. There is an error in the logs when trying to initialize the cam. Rebooting the device does not fix the issue. If I toggle power it starts to work again. The camera is not easily accessible so I was hoping the reset button could restore the camera state.

How about feeding power through a normally closed relay. When you want to power cycle turn the relay on, cutting the power. The relay then switches off and the esp power is restored.

Before I go that route wanted to check If it was possible to trigger the reset remotely. Sounds like it’s not an easy option at the moment?

I have a setup with latest hassio and a esp32 cam on my network.
The stream works fine in a browser, but when i try to have the stream in hassio i don’t get any picture at all.
I think i know the issue but i don’t have a solution for it, my access to home assistant is via duckdns and ssl but i don’t have a clue how to fix my stream.

Br
Fredric

Are you using esphome?

I hooked up a BH1750 Illuminance sensor to my esp32-cam (first time I’ve done that). Was easy and seems to be performing solidly.

Edit: Also now running a motor controller and a end stop switch (My take on a @DrZzs Motorised Automated Crank Window Opener)

I see a lot of configs passing by in this topic and noticed a lot don’t have an API password set. Why is that? Is it not advisable to use a password?

Yes but people often omit it from here as they are secret.

Ofcourse. Makes sense.

Ok. Stupid question…

What does this protect?
Well, the api server obviously, it says that in the docs. But what does that actually mean?

Yes I’m new to ESPHome. I’ve only been playing with it up until now but am about to use it ‘seriously’.

The password protects access to the esp device (it is the api server).

Without it, anyone could access your esp device.

However unlikely that sounds, it is better than leaving it open!

1 Like

Did anyone get the TTGO-T Camera Plus to work properly with homeassistant/esphome? Been fighting it for several months and no matter what I do it get’s a api block. If you got the answer please do share ^^

Try this you can remove the mqtt section if you dont need it

substitutions:
  devicename: "ttgocam"
  friendly_name: "woonkamer_camera"
  ip_address: ************
  ssid: 'WiFi_*********
  password: '***********'

esphome:
  "name": $devicename
  "platform": ESP32
  board: esp-wrover-kit

wifi:

  manual_ip:
    static_ip: $ip_address
    gateway: *************
    subnet: 255.255.255.0
  ssid: $ssid
  "password": $password
  fast_connect: True


# Enable logging
logger:

# Enable Home Assistant API
api:
font:
  - file: "Arial Black.ttf"
    id: my_font
    size: 18
  - file: "Arial Black.ttf"
    id: my_font1
    size: 20
  - file: "ComicSansMSRegular.ttf"
    id: my_font2
    size: 10
  - file: "ComicSansMSRegular.ttf"
    id: my_font3
    size: 16  
  - file: "Shadeerah.ttf"
    id: my_font4
    size: 18  
ota:


binary_sensor:
  - "platform": gpio
    pin: GPIO33
    "name": "$friendly_name PIR"
    device_class: "motion"
    id: "motion"

  - "platform": gpio
    pin:
      number: GPIO34
      mode: INPUT_PULLUP
      inverted: True
    "name": "$friendly_name Button"
    id: button

  - "platform": status
    "name": "$friendly_name Status"
    
switch:
  - "platform": gpio
    "name": "$friendly_name LED"
    pin: GPIO13
    id: relay
  - "platform": restart
    "name": "$friendly_name Restart"    

sensor:
  - "platform": wifi_signal
    "name": "$friendly_name WiFi Signal"
    "update_interval": 10s
  - "platform": "uptime"
    "name": "$friendly_name Uptime"

esp32_camera:
  "name": $friendly_name 
  external_clock:
    pin: GPIO32
    frequency: 20MHz
  i2c_pins:
    sda: GPIO13
    scl: GPIO12
  data_pins: [GPIO5, GPIO14, GPIO4, GPIO15, GPIO18, GPIO23, GPIO36, GPIO39]
  vsync_pin: GPIO27
  href_pin: GPIO25
  pixel_clock_pin: GPIO19
  power_down_pin: GPIO26
  resolution: 640X480
  jpeg_quality: 10
  vertical_flip: true
  horizontal_mirror: true

i2c:
  sda: GPIO21
  scl: GPIO22
text_sensor:
  - platform: mqtt_subscribe
    name: "ttgo1"
    id: text_ttgo1
    topic: ttgo1
  - platform: mqtt_subscribe
    name: "ttgo"
    id: text_ttgo2
    topic: ttgo2 
  - platform: mqtt_subscribe
    name: "ttgo"
    id: text_ttgo3
    topic: ttgo3   
  - platform: mqtt_subscribe
    name: "ttgo"
    id: text_ttgo4
    topic: ttgo4    


time:
  - "platform": homeassistant
    id: homeassistant_time

display:
  - "platform": ssd1306_i2c
    model: "SSD1306 128x64"
    address: 0x3C
    rotation: "180"
    lambda: |-
      if (id(motion).state) {
      it.printf(64,0, id(my_font), " %s",id(text_ttgo1).state.c_str(), TextAlign::BASELINE_CENTER);
      it.printf(64,42, id(my_font), " %s",id(text_ttgo2).state.c_str(), TextAlign::BASELINE_CENTER);
      }
      else {
      it.printf(64,0, id(my_font4), " %s",id(text_ttgo3).state.c_str(), TextAlign::BASELINE_CENTER);
      it.printf(64,42, id(my_font4), " %s",id(text_ttgo4).state.c_str(), TextAlign::BASELINE_CENTER);
      it.strftime(64, 64, id(my_font1), TextAlign::BASELINE_CENTER, "%H:%M", id(homeassistant_time).now());
      }
mqtt:
  broker: 192.168.1.111
  port: 1883
  username: **********
  password: ************
  client_id: woonkamer
  birth_message:
    topic: woonkamer/cam
    payload: online
  will_message:
    topic: woonkamer/cam
    payload: offline    
  on_message:
    - topic: woonkamer/cam/on_off
      qos: 0
      then:
        - switch.toggle: relay

This looks like the ttgo camera with motion sensor:) I have 2 of them and they work like a charm. It’s the ttgo plus that is the problem :slight_smile: but I can try the code with some pin change to see if it works :slight_smile:

Hi there - have you solved it?
Failed to call service camera/play_stream. camera.front_door_camera does not support play stream service

I have the same issue.

No not yet. My router broke down so I have not hade time to get it running but my first test did not work…

Hi,

I am struggling with the installation of a ESP32CAM AI Thinker in HA.
Here is my config:
- HA image installed on Rasp 3B+
- System HassOS 3.13
- MotionEye: 0.8.0

I would like to be able
- to monitor the camera from outside (SSL)
- set up motion detection, preferaly through Motion Eye

Others on the forum seem to have succeed.
I am sorry to bother you with something so stupid, but I am a total newbee, spent days searching the web and I simply cannot manage to setting both!

I have integrated the cam with ESPHome: remote viewing works perfectly.
I finaly managed to spot the stream url (https://xxxxxxx.duckdns.org/api/camera_proxy_stream/camera.cameranew?token=c7ca642xxx).
The url works ok in VLC.
Pb: when I plug the URL as IP camera in Motioneye, it identifies the type of camera, creates it, but does not receive the pics
(cf Motioneye logs: ERROR: mjpg client timed out receiving data for camera 1 on port 8081
[22/Apr/2020:21:26:14 +0200] 200 192.168.0.8, 172.30.32.1(172.30.32.2) GET /picture/1/current/?_=1587583568642&_username=admin&signature=09f7e4fab639ada1c2f8412dacbe5fe6832d2541 HTTP/1.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36)
[22/Apr/2020:21:26:20 +0200] 200 192.168.0.8, 172.30.32.1(172.30.32.2) GET /picture/1/current/?
=1587583574121&_username=admin&_signature=07b67c9adb47cc8707b8a2c7a65dd408e9ed09a9 HTTP/1.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36)
ERROR: mjpg client timed out receiving data for camera 1 on port 8081)
On the top of that, if I understood well what I red on the forums, the ESPHome token changes all the time and when I try to put a permanent token from profile, MotionEye won’t even create the cam…

I tryed the other way, by flashing the cam via Arduino, following various tutos, including this one (https://randomnerdtutorials.com/esp32-cam-video-streaming-web-server-camera-home-assistant/)
I easily got the stream (https://192.168.0.4:81/stream) and picture urls, as well as the settings’ webpage.
The cam is well integrated into MotionEye, motion detections, notifications work perfectly,…BUT…:
Streaming the cam on lovelace works poorly.
Whether I use the identity from the generic camera integration or the streaming URL of Motion Eye in lovelace picture card,…it doesn’t work…
It lags a lot, preload stream never ends,…
I have tried to change the 8081 port, nothing seems to work.

I have tryed to do without MotionEye, with scripts, but I only managed to take pictures. I get error message saying the cam does not accept recording, nor motion detection…far from expected result.
I would really like to use MotionEye, the app is great, 100% what I need.

I do not know, where I f… up : motioneye settings, parameters in Arduino flashing, tokens,…
Too many tracks to follow for my newbee’s knowledge!

Can somebody help me solve this nightmare puzzle or at least tell me where I should start looking?!

Thanks a lot

I finaly managed to spot the stream url (https://xxxxxxx.duckdns.org/api/camera_proxy_stream/camera.cameranew?token=c7ca642xxx).
The url works ok in VLC.

didn’t you forgot the port in this url??
port 8123

Thanks for helping me.
The URL is ok, because I copy it directly from the Lovelace picture card streaming.
I checked it with VLC, another browser, Lovelace and my mobile 4G, it works fine.
When I plug it in MotionEye as a network cam, it seems to recognize it directly as a Mpeg cam, it registers it, …but grey screen.
I have tried to change resolution, no impact…
I wonder if there is a conflict: you cannot use the same URL with MotionEye and Lovelace?
Strange…

But I do not know if I am on the right track, because the token seems to change very often.
I guess I will have to use a permanent profile one…