Home Automation / Projects · May 7, 2021

Solar-Powered IoT project: Firmware flash

Let’s get some ESPHome firmware flashed on to your ESP32 solar-powered IoT project! I’ll show you the basics of building the base firmware to get it attached to your WiFi network, some tips and tricks for working with mDNS across subnets, and leave you with a working OTA-managable solar-powered sensor! Code examples are below, as referenced in the video!

YouTube player

Flashing firmware via USB
If you’re trying to find your ESP32 / ESP8266 board after you plugged it in to USB, on macOS systems, you will want to go to Terminal, and run:
ls /dev/tty.usb*
.. which will output all usbserial devices attached.

Install ESPTOOL.PY
You’re going to need esptool.py for actually flashing the firmware .bin file. I’m going to send you over to the ESPTool GitHub Page for the most current instructions, but if you are familiar with using pip, then it’s as simple as running
pip install esptool
Once that’s loaded up, you’ll be ready to flash the firmware .bin you generated with ESPHome from the video tutorial

Flash ESPHome Firmware
Once you’ve compiled your .bin firmware and downloaded it locally, identified which usbserial device your ESP32 is attached to, and have esptool installed, you’re ready to flash your firmware! Run the below cmd, with your unique usbserial-xxxx port, and the correct .bin filename
esptool.py --chip esp32 --port /dev/tty.usbserial-12345678 write_flash 0x0000
That’s it! It should begin writing the firmware .bin file to your ESP32! Note: If you’re using an ESP8266 instead, drop the --chip esp32 from the command.

Examples from the ESPHome firmware code
A couple notes on what you see below:

  • domain: <– this is how you ensure your ESP is talking to the right FQDN namespace. Should match your home network internal domain name.
  • fast_connect: <– This allows you to connect to a hidden SSID network!
  • use_address: <– I didn’t talk about this in the video, but if you are having trouble with name resolution, you can tell ESPHome to go find your ESP on a specified IP address.

esphome:
name: esp32_01
platform: ESP32
board: wemos_d1_mini32

wifi:
ssid: "WiFi Access Point SSID"
password: "secretWifiPassword"
domain: .yourdomain.com
fast_connect: true
use_address: 192.168.0.150