Smart Home Controller – ESP32 + Relay + IR + ESPHome Integration

by Markus24152 in Circuits > Electronics

71 Views, 2 Favorites, 0 Comments

Smart Home Controller – ESP32 + Relay + IR + ESPHome Integration

Bild_2025-10-12_134911920.png
IMG_9728.jpeg

This Smart Home Controller is a compact ESP32-based module that can switch any AC or DC load via relay — either through Wi-Fi (ESPHome + Alexa + Home Assistant) or via an IR remote.

It’s fully custom-designed on a PCB and includes:

  1. An ESP32-WROOM microcontroller
  2. Relay output
  3. IR receiver (programmable for any button on your remote)
  4. Wide input range (up to 48 V with onboard step-down converter)
  5. Extra GPIO pin for extensions or sensors
  6. Powered by ESPHome firmware for easy integration


Supplies

ESP32-WROOM-32

Relay module SRD-05VDC-SL-C

IR Receiver TSOP38238

Step Down LM2596S-3.3

Diode 1N4007, SS34

Transistor BC817

Optocoupler PC817

Capacitors, resistors 0805

Screw Terminal

PCB from JLCPCB

Bild_2025-10-12_125852204.png
Bild_2025-10-12_130251848.png

📐 Circuit Design

The PCB connects the ESP32 with the relay driver circuit and IR receiver.

The GPIO for the relay is configured in ESPHome, while another GPIO is available for expansion (sensors, LEDs, etc.).

A buck converter regulates the wide input voltage down to 3V3.

💻 PCB Fabrication With JLCPCB

Bild_2025-10-12_130425289.png
Bild_2025-10-12_130533689.png
IMG_9726.jpeg

Ordering your custom PCB is simple and gives high-quality professional results. Here’s how I do it:

Click “Quote Now”, upload your Gerber zip.

Choose options:

  1. 2 Layers
  2. 1.6 mm thickness
  3. HASL / ENIG finish
  4. Green or any color you like


A special thanks goes to the nice girls and guys at JLCPCB for sponsoring PCBs manufacturing.

Without their contribution this project would have never seen the light, like many others projects of mine now.


🔧 Assembly

IMG_9727.jpeg
IMG_9728.jpeg

1️⃣ SMD Soldering

Start by soldering the small SMD components first (resistors, capacitors, transistor, etc.).

You can hand-solder with fine tip + flux or use a hot plate/reflow method.

2️⃣ Through-Hole Components

Next, solder:

  1. ESP32 header
  2. Relay
  3. Screw terminals
  4. IR receiver

3️⃣ Final Check

Ensure polarity of capacitors and diode are correct.

Power up via 5 V USB or external 12–48 V supply.

⚙️ Flashing the Firmware

esphome:
name: Controller
friendly_name: Controller

esp32:
board: esp32dev
framework:
type: arduino
# WLAN
wifi:
ssid: "your_wifi"
password: "yourPassword"

logger:

# Webserver für HTTP-GET
web_server:
port: 80
include_internal: true



remote_receiver:
pin:
number: 19
inverted: true
mode:
input: true
pullup: true
dump: all
on_lg:
then:
- if:
condition:
or:
- lambda: 'return (x.data == 0x20DF0DF2);'
then:
switch.turn_off: relay

- if:
condition:
or:
- lambda: 'return (x.data == 0x20DF5DA2);'
then:
switch.turn_on: relay

- if:
condition:
or:
- lambda: 'return (x.data == 0x20DF718E);'
then:
switch.toggle: relay

switch:
- platform: gpio
pin:
number: 18
inverted: false
name: "relay"
id: relay


📡 Testing

  1. Test relay switching via ESPHome dashboard.
  2. Train IR receiver with your remote button.
  3. Verify Wi-Fi connection and power consumption.