ESPHome is a great way to start DIY IOT. Thus, it can also be installed on existing devices like smart lights, plugs, power strip and more. In this tutorial, we’ll see how to use, configure and install ESPHome on a Sonoff Basic.
What is ESPHome ?
ESPHome is an ecosystem which allows to control the hardware connected to ESP8266/ESP32 devices.
Using simple configuration files, it’s able to control LED strips, temperature sensors, inputs, outputs, i2c devices and a lot more.
Have a look at their site to see what it can do.
Also used :
First of all, we need to connect the Sonoff’s board to the serial adapter in order to be able to flash it.
Except the wire connection covers, there is no screw to remove. We only have to use a screwdriver to open the box.
Then, we can solder a 5 pins header on the board.
Connect to the Serial Adapter
There is multiple ways to upload a new firmware on the ESP8266. On our side, we’ll install it with Python 3.
On ESPHome, everything comes from a configuration file. This YAML file contains the different information regarding the connections, inputs, outputs and devices. Their website contains all the information about how to configure the sensors connected to the ESP8266.
Regarding specifically the Sonoff Basic, here is a sample of the configuration :
To use Python to upload the firmware, we need a Python 3 installed, this can be found here if you don’t already have it.
A Python package already exist to manage everything around the configuration and the upload. I can be installed by running the following command :
pip install esphome
Then, put your Sonoff Basic in the programming mode :
- Unplug your Serial Adapter
- Press the push-button on the device (keep it pushed)
- Plug your Serial Adapter
- Release the button
Your device is now ready for the firmware upload, it can be done with this command :
esphome my_awesome_node.yaml run
That’s it ! We’re now have ESPHome on a Sonoff Basic, and the node is connected to Home Assistant.
A lot of IOT devices are made with an ESP8266 and most of them can be flashed without trouble. It’s also easy to add sensors to them.
Stay tuned, I’ll post other projects and tutorial related to ESPHome, ESP8266 and Home Assistant !