Home Assistant: Simple relays with ESPhome

To further my quest in replacing my underfloor heating controller with self built Domotica today I’m taking a look at some ultra cheap Chinese relay boards to see if they could work in case (spoiler, they are great!)

It’s a video again

As it common by now I made a video about the whole setup including how to hook it up and configure it! Check it out. 🙂

Shopping links:

MH-ET Live ESP32: http://geni.us/4OZdAj
or
Wemos D32 Mini: https://geni.us/9aXV

Good Micro-USB cable: https://geni.us/4Yqui9t

Good Phone charger that can deliver 5v 2A (10w) on a single port: https://geni.us/TiSqB

1x, 2x, 4x or 8x Relay board with Optocoupler and 3.3v trigger: https://geni.us/dRYwMJK

ESPhome

I think the video explains most things pretty clearly. As mentioned in the video if you don’t know how to create, compile and upload the ESPhome code, check out my previous temperature and/or tuya power plug videos which show you the process in detail!

ESPhome code

In the video I do refer to some ESPhome code, here it is:

esphome:
  name: relaynode
  platform: ESP32
  board: mhetesp32devkit

wifi:
  ssid: 'WIFI NETWORK'
  password: 'WIFI PASSWORD'

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: 'HA API PASSWORD'

ota:
  password: 'OTA PASSWORD'
  
web_server:
  port: 80

switch:
  - platform: gpio
    name: "test_lights_deca Onboard light"
    pin: 2
    inverted: True
    restore_mode: RESTORE_DEFAULT_OFF
    
  - platform: gpio
    name: "Relay_1"
    pin: 25
    inverted: True
    restore_mode: RESTORE_DEFAULT_OFF
    
  - platform: gpio
    name: "Relay_2"
    pin: 26
    inverted: True
    restore_mode: RESTORE_DEFAULT_OFF
    
  - platform: gpio
    name: "Relay_3"
    pin: 27
    inverted: True
    restore_mode: RESTORE_DEFAULT_OFF
    
  - platform: gpio
    name: "Relay_4"
    pin: 14
    inverted: True
    restore_mode: RESTORE_DEFAULT_OFF

 

Please follow and like us:

2 thoughts on “Home Assistant: Simple relays with ESPhome”

  1. Please don’t mind the noob question. But what changes should I make to use a, let’s say, 8 or 16 relay board?

    1. Each relay is connected to a single GPIO pin so if you want to use more relays (on the same board or multiple boards) you just need to add more GPIO connections between the relay board and the ESP module. In the code you then copy the relay lines and add the GPIO pins used for the additional relays and they will automatically appear in Home Assistant!

Leave a Reply

Your email address will not be published. Required fields are marked *