add a Relay Board ESP32 - ESPHome

 

To be able to switch certain relays in Home Assistant via an ESP32, I tested a relay board and integrated it via ESP-Home.

Necessary hardware

Besides an appropriate hardware for Home Assistant, I married an ESP32 with a 4-channel relay board: 

Wiring

As GPIO-PINs I used the PINS G25,26,32 and G33 for testing:

ESP-Home

If you already have the ESP32 connected to Home Assistant, you can add the relay board with the following lines:

...
switch:
  - platform: gpio
    pin: GPIO32
    name: Relay1
    id: relay1
  - platform: gpio
    pin: GPIO33
    name: Relay2
    id: relay2
  - platform: gpio
    pin: GPIO25
    name: Relay3
    id: relay3
  - platform: gpio
    pin: GPIO26
    name: Relay4
    id: relay4

This will make the relays show up as "controls" in Home Assistant.

Use in practice: Heating control

Control heating with Home Assistant

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Updated: 2024-04-28 von Bernhard | Übersetzung Deutsch |🔔 | Comments:0

ESPHome: Temperature and humidity sensors DHT11/22 | ESP32 | DS18B20 Temperature Sensors ESP32, MQTT and WiFi - HowTo

Top articles in this section


ESP32 Flowmeter and RS485 Modbus

As described on the article ESP32 programming, Arduino - install requirements, my first goal was to read out a TUF-2000M Ultrasonic Flow Meter via an ESP32. I found an example for an ESP8266 on the internet: Reading a TUF-2000M Ultrasonic Flow Meter with an Arduino or ESP8266 and https://forum.arduino.cc/t/comunicacion-rs485/698786/2. I described the setup of the TUF-2000M in the following article: Field Report: Ultrasonic Flow Meter TUF-2000M. To be able to read out the TUF-2000M via RS485, it...


DS18B20 - Temperature sensors in ESP-Home

Complementary to the article: DS18B20 Temperature Sensors ESP32, MQTT and WiFi - HowTo, I have meanwhile replaced the Arduino project with ESP-Home. Simple projects can be implemented much easier in ESPHome. As an example, in ESPHome these 2 lines are enough to address the temperature sensors:


Home Assistant + DIY Microcontroller + ESP Home (Docker)

With ESPHome it is very easy to program your own microcontroller for use in HomeAssistant. My first use for a self-programmed microcontroller was to record the water flow and temperature values of my heater, see: ESP32 programming, Arduino - install requirements.

Questions / Comments


By continuing to browse the site, you agree to our use of cookies. More Details