ESP32 Cam - working!

For those that want a howto, here goes. It’ll be pretty brief as most the actual setup in esphome is covered by @OttoWinter in the esphome docs.

As said above my device is this https://www.aliexpress.com/item/1pcs-ESP32-CAM-WiFi-WiFi-Module-ESP32-serial-to-WiFi-ESP32-CAM-Development-Board-5V-Bluetooth/32955484091.html?spm=a2g0s.9042311.0.0.79984c4dNbGPlZ

These things are all over aliexpress. This particular one is around US$10 and seems to be identical to the Ai-Thinker design.

These particular boards have no usb port attached (unlike many esp32 dev boards). Therefore to join it to your esphome computer you need a USB to Serial programmer. The best ones seem to have the CP2102 chip. Again there are plenty of places to buy these. They have four pins to connect to the ESP32-Cam board.

CP2102                  ESP32-CAM
  3v3                     3v3
  GND                     GND
  RXD                     UOT
  TXD                     UOR      

Also you need to short GPIO0 to GND when doing the initial serial flash to put it in programming mode. Don’t forget to unshort it when restarting. Once we have done the initial USB flash, all future flashing can be done OTA, so make sure you include OTA in your esphome yaml file. Thanks to the author of this page for those wiring details: https://robotzero.one/esp32-cam-arduino-ide/

After that is all done, write a yaml file including the camera setup from here - I copied and pasted the AI-Thinker example and it worked perfectly. https://esphome.io/components/esp32_camera.html

After you have flashed and restarted (not forgetting to unshort GPOI0) you should get a device appearing in home assistant via Integrations. Once you add the new device, there will be a camera entity.

Hope this helps someone.

16 Likes

I have one also and got it to work but it is not stable, after a couple of hours it needs to be reset.
Which board did you select when setting it up under esphome? I chose esp-wrover-kit but I’m unsure if that is the correct one.

esp32dev, but I am by no means sure what is right.

1 Like

Thank you, seems to work, I will let you know tomorrow if it needed to be reset.

Thanks you, choosing esp32dev did the trick, it’s been on since last night.

Waiting for someone to round this out as a project that includes IR lighting, day / night mode switching and is generally stable for continuous use.

This would make having MANY cameras very inexpensive.

I’d love to see such a project, too.

but you’ll most likely need a reasonable expensive WiFi AP/router to cope with MANY camera streams… :wink:

Depends on the bitrate and resolution. I have a multiple AP Ubiquiti setup one of the easier ways getting around wifi bandwidth is to have more APs spread out near the devices at low power so they do not overlap.

However you are correct that streaming is really hard on wifi.

Hence my wish for a POE ethernet version!

1 Like

hello

I bought one of these esp32 cam boards off amazon
https://www.amazon.co.uk/MakerHawk-M5Stack-Antenna-Arduino-Raspberry/dp/B07F2DNX6M/ref=sr_1_1_sspa?keywords=M5Stack+ESP32+Camera+Module&qid=1554793385&s=electronics&sr=1-1-spons&psc=1

However i cannot get it to flash, i presume the reset button should set it to flash mode, can anyone confirm or as anyone used one like this?

The board comes preprogrammed as an access point but you can only get live stream from the 192.168.4.1 address no config options, so can only have an adhoc connection.

cheers

I have that exact same board and just held the reset button while plugging it in that seemed to put it in flash mode.
I used a USB C to micro USB adaptor.

There are plenty of options about, eg this one with an OLED, a PIR sensor and two buttons, for about US$20, ie roughtly twice the price of the bare unit with the fairly un-useful SD card reader.

If anyone has got this particular board [TTGO-Camera] that Nick’s suggested to work I’d be grateful for seeing the ESPHome config you used. Flashing it with a USB cable from the ESPHome web manager interface is fine - no button pressing or anything else was needed, but the particular camera won’t correctly reply to the SCCB probe, and so fails to configure correctly. It happily does all the other things it should (talks to HA, syncs time, provides web server i/f etc).

I can’t determine if it’s the ov2640 camera itself that isn’t defined in the source perhps, or if it’s because the BME220 chip is not present (which seems unlikely) on the examples I have. The boards all worked OK on delivery with their supplied app software, so I don’t have any reason to suppose they are actually defective as such.

1 Like

this is what I have for the TTGO, I’m not able to get the camera image though, it say it’s sending it in the logs but I never get it in HA.

esphome:
  name: camera
  platform: ESP32
  board: esp-wrover-kit

wifi:
  ssid: ""
  password: ""
  ap:
    ssid: camera_test
    
# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

esp32_camera:
  name: My Camera
  external_clock:
    pin: GPIO32
    frequency: 20MHz
  i2c_pins:
    sda: GPIO13
    scl: GPIO12
  data_pins: [GPIO4, GPIO5, GPIO14, GPIO15, GPIO18, GPIO23, GPIO36, GPIO39]
  vsync_pin: GPIO27
  href_pin: GPIO25
  pixel_clock_pin: GPIO19
  power_down_pin: GPIO26
  resolution: 640x480
  jpeg_quality: 10

i2c:
  sda: GPIO21
  scl: GPIO22

font:
  - file: "Ubuntu-Regular.ttf"
    id: ubuntu
    size: 20

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    address: 0x3C
    lambda: |-
      it.print(0, 0, id(ubuntu), "Hello World!");

sensor:
  - platform: bme280
    temperature:
      name: "BME280 Temperature"
      oversampling: 16x
    pressure:
      name: "BME280 Pressure"
    humidity:
      name: "BME280 Humidity"
    address: 0x77
    update_interval: 60s

binary_sensor:
  - platform: gpio
    pin: GPIO33
    name: "PIR Sensor"
    device_class: motion

I think from the last photo in the aliexpress listing for the TTGO with PIR etc that this should be

data_pins: [GPOIO5, GPIO14, GPIO4, GPIO15, GPIO18, GPIO23, GPIO36, GPIO39]

ie, the same order as in the pic. This is a parallel data bus, so order will be important.

PS I ordered one, when the canoe arrives with it I’ll give it a try!

I had that originally and i couldn’t even get the epshome log to show it was sending images. I re-ordered them to be in numerical order and I was at least getthing the log showing that an image was sent, just nothing in HA.

I managed to get this working too without any issues with the AI thinker board. I can confirm you can add other sensors, have got a DHT 22 running along side too. I was thinking of possibly switching it for a PIR or something (accidentally got the APD 9330 instead of the 9600…).

This might be a silly question but is there a stream URL for the esp32cam? I couldn’t seem to find any documentation related to that anyhwere?

1 Like

I have the ai thinker version and did get the led also to work.

switch:

  • platform: gpio
    pin: GPIO4
    name: “Camera Light”
5 Likes

+1 this.

I’d be interested to know if the output from the camera successfully ties in with the new camera support in 0.91, for example streaming to a chromecast.

1 Like

This is one of the reasons I was also looking for this!

Unfortunately attempting to cast it brings up “Failed to call service camera/play_stream. camera.esp32cam does not support play stream service”. Also there is nothing in config relating to esp32cam that I can tack the necessary stream_source onto.

Im running Hass.io on a raspb pi, and was hoping I would be able to process the stream for motion or light intensity but can’t find access to it in any way!?