view the full post on our website: ESPHome Beginner Tutorial
esphome:
name: sensor-name
friendly_name: sensor-name
platform: ESP8266
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "xxxAUTOGENERATEDxxx"
ota:
- platform: esphome
password: "xxxAUTOGENERATEDxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Sensor-name Fallback Hotspot"
password: "xxxAUTOGENERATEDxxx"
web_server:
port: 80
captive_portal:
i2c:
sda: D6
scl: D5
scan: true
id: bus_a
binary_sensor:
- platform: gpio
pin:
number: D2
mode: INPUT_PULLUP
inverted: true
name: "Motionsensor"
- platform: gpio
pin: D7
name: "Button"
on_press:
then:
- switch.toggle: relay1
switch:
- platform: gpio
name: "Relay1"
pin: D3
id: relay1
- platform: gpio
name: "Relay2"
pin: D4
sensor:
- platform: bh1750
name: "BH1750 Illuminance"
address: 0x23
update_interval: 10s
- platform: ultrasonic
trigger_pin: D0
echo_pin: D8
name: "Distance Sensor"
update_interval: 1s
- platform: dht
pin: D1
temperature:
name: "Temperature"
humidity:
name: "Humidity"
update_interval: 5s