Homemade ESP32 webcam

Homemade ESP32 webcam

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 naughty again and digging holes.

Actually, there is no problem. I just like to tinker.

The solution:

A cheap webcam (10€) integrated in .

HW parts:

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

SW:

Tools:

  • soldering iron (too bulky)
  • soldering flux
  • tweezers with a thin tip (the ones that came with 3d printer)
  • magnifying glass with a LED light
  • vise (for holding the board steady)
  • shaky hand
  • a bit of patience

The process:

The ESP32-CAM camera comes with an internal and external antenna. To use the external antenna, a small resistor on the board 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 vise

It took me quite some time and burned fingers to solder a resistor. It’s probably the size of 0603 (metric). Luckily I didn’t fry the electronics. Here’s the photo under a magnifying glass, red circle:

esp32 cam board closeup, with small resistor encircled

2. Then I searched for the appropriate case on Printables. I liked this 3D model, because it has ventilating holes at the top, a stand and a hole for the antenna and it looks nice. I used some remaining PLA filaments of various colours:

3d printed enclosure of the esp32 cam, pink, white,blue colours, from behind

I 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:

* heating the drill using a small propane torch

3d printed enclosure of the esp32 cam, pink, white,blue colours, front view

4. I flashed the board with ESPHome firmware (actually I did it before the assembly to see if it survived soldering). I used an online ESP32Home 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 via USB succeded.

After the first flashing with a connected USB cable, all the next ones can be done via wi-fi.

ESPHome configuration

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

ESP32-Cam exposes the following entities to HA:

  • 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 the above functionalities:

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 webcam

The 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 webcam

Conclusions/Key takeaways

Except for 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:


Posted

in

, , , , ,

by

Comments

4 responses to “Homemade ESP32 webcam”

  1. Iznogoud Avatar

    @tomi nice build, thanks for sharing!

    1. Tomi the Slav and 1024 others Avatar

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

      1. Iznogoud 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.

        1. Tomi the Slav and 1024 others Avatar

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

Leave a Reply

Your email address will not be published. Required fields are marked *