My Experience with ESPHome on Home Assistant Using and ESP32 Camera/Motion Module

So as someone that has a blog that mainly has posts that either relate to the ESP8266 or Home Assistant, I feel like I should have been using ESPHome a long time ago. TL;DR: If you have ESP8266 devices and Home Assistant, you should absolutely be moving stuff to ESPHome. I plan on moving my Garage Door, Fireplace, and Sump Pump Monitor over to ESPHome.

Anyways, I read about how Home Assistant added support for ESP32 based cameras on ESPHome. That piqued my interest, so I bought one, and decided that would be the first device I use ESPHome with.

NOTE: The one that I bought is the same as the links above, but mine doesn’t have the BME280 sensor for temperature, humidity, and pressure. As you can see in pictures, it has a spot for the tiny sensor, but no sensor. I didn’t realize that when I bought it, or else I would have gotten that version. The ones in the links above have the sensor, and I’ve got code below to enable the sensor. You will just need to uncomment it.

NOTE2: I’m using Hass.io with the ESPHome add-on. That makes things a lot easier to manage your ESPHome devices. So if you’re not running Hass.io, you will likely have more steps you need to do, which I am not going to be too familiar with.

Install the ESPHome Addon. In Home Assistant (HA), go to the Hass.io panel -> Add-on Store. Add https://github.com/esphome/hassio as an add-on repository. Click on the ‘ESPHome’ addon and install it, and start it. Click on “Open Web UI” and login with your HA login.

Click the ‘+’ button to create an ESPHome node. Enter a name for it, and select the device type. In my case, it was the Generic ESP32 (WROVER Module). Put in your WiFi information and then submit.

Compile the firmware. Click the 3dots on the new node and click ‘compile’. It can take a minute or 5 this first time.

Upload the firmware to the ESP32. If you just connect the ESP32 directly to your HA computer/Pi, then at the top right select the TTY for the ESP from the dropdown, and then just click Upload on the node. This will take a minute or so.
Alternatively, if you are like me and your HA instance is in your basement, and you don’t feel like plugging directly into it, you can download the binary using the link at the bottom of the compile dialog from step 3. After downloading the file, follow the steps below to upload it from your PC:

Run these commands from the command line. I’m thinking it should be the same for any OS, but I was using Win10. I ran it from the Win10 command line, not the python command line.

pip3 install wxpython

pip3 install esphomeflasher

esphomeflasher

That should open up a nice little gui. Select the ESP32 COM port, browse to the binary file you downloaded and flash it.

In ESPHome, it should show online after a few minutes. For this node, you can now upload all future firmware updates to it over WiFi, without connecting it to the computer. When we created the node, all it did was upload firmware that allows it to connect to WiFi and talk to ESPHome. Now we will make changes to the YAML for that node to add functionality to the firmware.

Under the node in ESPHome, click ‘Edit’. Add the following code to the end of the existing code. If you got a unit with the BME280 sensor, be sure to uncomment those lines. For the display/font config, you will need to download that font(or whichever font you want to use) and copy it to your Hass.io ‘config/esphome’ directory. Then Save and Close:

Upload the code again. You can upload it over the USB if you want, but Over-The-Air (OTA) updates should work now. Just select OTA from the drop down at the top right. The click Upload. Any time you add or remove components to the node, it has to completely recompile, which takes a few minutes. If you just make minor changes to a node’s component, then it takes about 30 seconds. Note the IP address of the node in the logs after it finishes uploading.

Add the Integration in HA. In HA, go to Configuration -> Integrations. Configure the ESPHome. Give it a name. It will ask for a password if you set one when configuring the node. Now, the camera, PIR sensor, and the BME280 sensor should show up in HA.

And that’s it. I really wish ESPHome was around when I first got into this. It would have made things so much easier than having to write the code for each project. Something that took me a couple days to code could have been done in 20 minutes. Hopefully this is useful to someone. Feel free to comment below if you have any questions.