/homeassistant-esp32cam-streamer

Primary LanguageC++Creative Commons Zero v1.0 UniversalCC0-1.0

homeassistant-esp32cam-streamer

GitHub

Based on bnbe-club/rtsp-video-streamer-diy-14 and the accompanying YouTube video

Instructions

  1. This will come with a programmer board; the ESP32-CAM doesn't have a USB port for programming so an external board is connected using the GPIO pins. Once you have the programmer, you can buy just the ESP32-CAM alone for cheaper at the same URL as above. The shipping is a flat fee so if you plan to use multiple ESP32-CAMs, get them all at the same time to save on overall shipping cost.

  2. Install and Configure Arduino IDE

    2.1. Download and install the Arduino IDE

    2.2. Open Arduino IDE and go to File > Preferences and enter https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json into the Additional Board Manager URLs field. If you have already have one there, just separate them with commas

    2.3. Go to Tools > Board > Board Manager and search for esp32. Click the install button in the bottom right (hover your mouse over the search result to show it).

    2.4. Go to Tools > Board > ESP32 Arduino and select AI Thinker ESP32-CAM from that menu.

    2.5. Open wifikeys.h and type in your router's WiFi credentials

    2.6. Go to Tools > Port and just take a note of what ports are currently available. Plug your ESP32-CAM into the programmer and use a USB cable to plug the programmer into the computer. Going back to Tools > Port, there should be a new entry, select the new one.

    2.7. Go to Sketch and click Upload. This might take a while and stress your CPU a little, that's normal.

    2.8. Go to Tools and click Serial Monitor. Change the Baud Rate to 115200 and you should see WiFi connected followed by an IP address. Go to your browser and type in that IP address into the address bar and you should see the camera feed as a stream of JPEG images.

  3. Integrate into Home Assistant

    3.1. Open your configuration.yaml file and add the following entry:

    camera: # if you already have a camera entry, rename this "camera 1", "camera 2", etc.
       - platform: mjpeg
         name: Garage Camera # rename this to whatever you want
         mjpeg_url: http://192.168.0.54 # this is the IP address from step 2.8
         still_image_url: http://192.168.0.54/still # this is also the IP address from step 2.8

    3.2. Restart Home Assistant

    3.3. Add a new Picture Entity card and for the Entity field select your new camera entity. The entity name will be based on the name entered in configuration.yaml. In the example above, the entity would be named camera.garage_camera

  4. Tweak the results

    Now that everything is set up, you can modify the code to better suit your needs. In particular, you can change the config.jpeg_quality value to lower (better quality but lower framerate) or higher (lower quality but higher framerate). When you are done making modifications, just rerun steps 2.6 and 2.7 to see your changes.