Today we will be taking a look at setting up your first ESPhome device in Home Assistant.
Introduction
“ESPHome is a tool which aims to make managing your ESP boards as simple as possible. It reads in a YAML configuration file and creates custom firmware which it installs on your ESP device. Devices or sensors added in ESPHome’s configuration will automatically show up in Home Assistant’s UI.“
Source :Getting Started with ESPHome and Home Assistant — ESPHome
For more information on how to install esphome feel free to take a look at This guide
Things needed
- ESP8266 or ESP32 Device
- Power supply to power the ESP 3.3v/USB
- USB Data cable (since we will be using a esp board that has a usb port) or usb to TTL
- Home Assistant with Esphome addon Installed
- Sensor module/s in this guide we will be using a relay and a DHT11 temperature and humidity sensors.
- Jumper/dupont cables depending on how you will be connecting the devices together
Secrets file code used.
Currently in my secrets file I have only added my wifi credentials this is to simplify setup of future devices and we will be discussing this more in the future.
wifi_ssid: "YourWifiNetowkname"
wifi_password: "YourWifiPassord"
Code for single relay
Remember to confirm you are using the correct GPIO pin.
switch:
- platform: gpio
pin: GPIO05
inverted: true
name: "Relay"
If you are using a different relay and the on/off switch is inverted you can change the option “Inverted” to “false” instead of true.
Code For DHT11
sensor:
- platform: dht
pin: GPIO04
temperature:
name: "DHT Temp"
humidity:
name: "DHT Humidity"
update_interval: 10s