This repository contains the code discussed in the book Getting Started with ESPHome, published by Elektor International Media, as well as a list of errors and their corrections and some additional tips and references.
Espressif's ESP8266 and ESP32 microcontrollers have brought DIY home automation to the masses. However, not everyone is fluent in programming these microcontrollers with Espressif's C/C++ SDK, the Arduino core, or MicroPython. This is where ESPHome comes into its own: with this project, you don't program your microcontroller but configure it.
This book demonstrates how to create your own home automation devices with ESPHome on an ESP32 microcontroller board. You'll learn how to combine all kinds of electronic components and automate complex behaviours. Your devices can work completely autonomously, and connect over Wi-Fi to your home automation gateway such as Home Assistant or an MQTT broker.
By the end of this book, you will be able to create your own custom home automation devices the way you want. Thanks to ESPHome and the ESP32, this is within everyone's grasp.
- Set up an ESPHome development environment and create maintainable configurations
- Use buttons and LEDs
- Sound a buzzer and play melodies
- Read measurements from various types of sensors
- Communicate over a short distance with NFC, infrared light, and Bluetooth Low Energy
- Show information on various types of displays
The directory esphome contains all YAML files for the example code in this book. Each file name begins with the chapter where the example is explained.
While the examples printed in the book are often fragments of code, the corresponding YAML files in this repository are complete ESPHome configurations and can be compiled as such. Make sure to copy the secrets.yaml.example file to secrets.yaml
and enter your own credentials. Also change the substitutions in the beginning of a YAML file to your own preferred values.
You can download the code all at once with Git:
git clone https://github.com/koenvervloesem/Getting-Started-with-ESPHome.git
The code is then downloaded into the directory Getting-Started-with-ESPHome
.
You can also download a ZIP file of all code by clicking on the green button Code at the top right of this page and then on Download ZIP.
Just selecting and copying code from the GitHub web page of a specific file you're interested in and pasting it in an editor may work, but is not recommended. Especially with YAML code the whitespace can become mixed up, which results in invalid code.
See the ERRATA document for the list of errors in the book and their corrections.
See the ADDITIONS document for some additional tips and references to interesting projects not mentioned in the book.
All code is provided by Koen Vervloesem as open source software with the MIT license. See the LICENSE for more information.
The included Roboto font is licensed under the Apache License, Version 2.0.
The uFire_SHT20 library is licensed under the MIT license.
The C++/runtime codebase of the ESPHome project (file extensions .c, .cpp, .h, .hpp, .tcc, .ino) are published under the GPLv3 license. The Python codebase and all other parts of the ESPHome codebase are published under the MIT license. See the ESPHome License for more information.