tomi,

Link to the original blog post with a nice text/pictures layout.

The problem:

  • I want to see what’s happening around the house, especially if the dog is naught and digging holes.
  • Actually, there is no problem. I just like to tinker.

The solution:

HW parts:

  • esp32 cam (I ordered the variant with USB hat and external antenna)
  • 3Dprinted enclosure
  • USB cable and power supply

SW:

The process:

The camera comes with internal and external antenna. To use the external antenna, a resistor must be resoldered (instructions).

  1. I re-soldered a tiny resistor near the antenna connector to switch the antenna from internal to external. It would be great if the board producer used some kind of jumper instead. I know, the costs.

esp32 cam board ready for soldering, in a viseIt took me quite some time and burned fingers to solder a resistor. It’s probably the size of 0603 (metric). Here’s the photo under a magnifying glass, red circle:

esp32 cam board closeup, with small resistor encircled2. Then I searched for the appropriate case on Printables. I liked this 3dmodel, because it has a stand and a hole for the antenna. I used some remaining filaments of various colours:

3d printed enclosure of the esp32 cam, pink, white,blue colours, from behindI had to enlarge (using a special technique involving a hot drill) the bottom-right hole because the onboard LED on my board was slightly shifted:

3d printed enclosure of the esp32 cam, pink, white,blue colours, front view4. I flashed the board with ESPHome firmware (actually I did it before the assembly). I used an online flasher. I had some issues – I still don’t know which button to hold during the start of the board (left or right). Anyways, after some retries flashing succeded.

ESPHome configuration

Then I searched for various pieces of code on the ESPHome community forums and blogs (1, 2, 3) and came up with this:

ESP32-Cam exposes the following entities:

  • a camera
  • a switch (for the white LED)
  • a switch (for the red status LED)
  • a slider (for the white LED brightness)
  • a switch (for restarting a board)
  • a binary sensor (for the status of the board).
  • it is accessible as a web server on port 8080 (stream) and 8081 (still pictures).

The ESPHome yaml code to achieve above functionalities:

... skipping the first part, wifi connectivity, substitutions etc.esp32_camera:  id: espcam  name: esp-cam  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: 1280x1024  jpeg_quality: 10  # max. 63  max_framerate: 10.0fps  idle_framerate: 0.1fps  vertical_flip: False  horizontal_mirror: false  brightness: 2 # -2 to 2  contrast: 1 # -2 to 2  special_effect: none  # exposure settings  aec_mode: auto  aec2: false  ae_level: 0  aec_value: 300  # gain settings  agc_mode: auto  agc_gain_ceiling: 2x  agc_value: 0  # white balance setting  wb_mode: autoesp32_camera_web_server:  - port: 8080    mode: stream  - port: 8081    mode: snapshotoutput:# white LED  - platform: ledc    channel: 2    pin: GPIO4    id: espCamLED# red status light  - platform: gpio    pin:      number: GPIO33      inverted: True    id: gpio_33light:  - platform: monochromatic    output: espCamLED    name: esp-cam light  - platform: binary    output: gpio_33    name: esp-cam ledswitch:  - platform: restart    name: esp-cam restartbinary_sensor:  - platform: status    name: esp-cam status   #slider for lednumber:  - platform: template    name: Camera Led Slider    optimistic: true    min_value: 0    max_value: 100    step: 1    mode: slider    on_value:      then:        lambda: 'id(espCamLED).set_level(x/150);'

Home Assistant

I’ve set up a simple dashboard in Home Assistant that shows idle preview (0.1 fps), uptime, switches for white LED and status led and a slider for adjusting white LED.

home assistant screenshot showing various data about webcamThe image below shows various statuses related to the ESP32 board, like restart switch, firmware, connection status, IP, firmware version and WIFI signal (the code above does not include these entities).

home assistant screenshot showing various data about webcamConclusions/Key takeaways

Except the soldering, this DIY camera is not too difficult to build.

The image quality is ok-ish (1600×1200).

The framerate is okay-ish for special purposes (e. g. door camera, environment camera). I get about 3-5fps in my case (different floor than the wifi router).

It is more stable than my other ‘IP webcam’ app running on Android phones. This app keeps stopping every few days, while ESP32 is stable.

TODO

What still remains is:

  • I’d like to adjust the brightness etc. on the fly (without recompiling the firmware), but I didn’t find the appropriate .yaml code for it.
  • integration in MotionEye (for recording the videos and motion detection) or Frigate (for object detection). I tried to integrated it to MotionEye, but it is very slow or the stream is mostly broken.

Disclaimer

The links to the products are not affiliate links and I don’t receive any compensation for linking.

The code and the ideas are mostly from HomeAssistant and ESPHome community forums.

Hashtags:

https://blog.rozman.info/homemade-esp32-webcam/

esp32 cam board ready for soldering, in a vise
3d printed enclosure of the esp32 cam, pink, white,blue colours, from behind

iznogoud,
@iznogoud@mastodon.social avatar

@tomi nice build, thanks for sharing!

po3mah,
@po3mah@mastodon.social avatar

@iznogoud @tomi Glad you like it! Sometimes I have doubts if such a very basic builds interest anyone.

iznogoud,
@iznogoud@mastodon.social avatar

@po3mah @tomi actually everyone can do beautiful things with a supersized machine.

But for me the really interesting stuff is how much can one get from small wonders such as ESP devices or Pis.

I was happy to know that one can use esp home w an esp cam and also to see which are the HA controls exposed by it 🙂

I would not use it for any reliable stuff due to wifi but looks nice for an ad hoc use / small projects / tinkering etc.

po3mah,
@po3mah@mastodon.social avatar

@iznogoud @tomi I found out esp32cam is much more reliable than my other 2 android ip cams (old samsung phones).

  • All
  • Subscribed
  • Moderated
  • Favorites
  • homeassistant
  • DreamBathrooms
  • mdbf
  • ethstaker
  • magazineikmin
  • cubers
  • rosin
  • thenastyranch
  • Youngstown
  • osvaldo12
  • slotface
  • khanakhh
  • kavyap
  • InstantRegret
  • Durango
  • JUstTest
  • everett
  • tacticalgear
  • modclub
  • anitta
  • cisconetworking
  • tester
  • ngwrru68w68
  • GTA5RPClips
  • normalnudes
  • megavids
  • Leos
  • provamag3
  • lostlight
  • All magazines