Skip to content

ESP32 IoT Home Automation Project

ESP32 IoT Home Automation Project to Control 4 Outputs via WiFi


This ESP32 IoT Home Automation Project allows you to control 4 outputs via WiFi efficiently. Using ESP32, relays, and optocouplers, this home automation project provides secure switching of 4 devices. The ESP32 IoT Home Automation Project includes BC547 transistors, 1N4007 diodes, LEDs, 1K resistors, 3-pin terminals, and a 7805 voltage regulator. With the ESP32 IoT Home Automation Project, you can control lights, fans, or other home appliances remotely.

This ESP32 IoT Home Automation Project guide explains the circuit, components, and step-by-step build instructions. Follow this ESP32 IoT Home Automation Project tutorial to make a reliable WiFi-controlled system. Implement this ESP32 IoT Home Automation Project and integrate it into your smart home setup seamlessly.


Introduction

Home automation is becoming increasingly popular, and controlling appliances via WiFi adds convenience and efficiency. This ESP32 IoT Home Automation Project allows you to control four devices remotely using a WiFi connection. It’s built with relays, optocouplers, and supporting electronics for safe and reliable operation.

With this project, you can automate lights, fans, or other small home appliances and integrate it with any IoT platform. The ESP32 provides built-in WiFi, making it an ideal microcontroller for home automation.


 Materials for the Project

S.NoComponentQuantityBuy Link
1ESP32 Board1Buy Link
26V Relay4Buy Link
3PC817 Optocoupler4Buy Link
4BC547 NPN Transistor4Buy Link
51N4007 Diode4Buy Link
61K Resistor12Buy Link
7LED4Buy Link
83-Pin Terminal4Buy Link
97805 Voltage Regulator1Buy Link

Useful Tools 

ToolQuantityPurpose / NotesClick & Buy
Soldering Iron Kit1For making permanent connectionsClick & Buy
Solder Wire (60/40, 0.8mm)1Electrical solderingClick & Buy
Wire Stripper & Cutter1Stripping jumper wiresClick & Buy
Mini Screwdriver Set1For module and relay terminal screwsClick & Buy
Multimeter1Testing voltages and continuityClick & Buy
Hot Glue Gun (optional)1Securing components in placeClick & Buy
Small Pliers1Holding and bending wiresClick & Buy
Heat Shrink Tubing Set1Insulating exposed wiresClick & Buy

ESP32 Pinout.

PinTypeTypical UseNotes
3V3Power3.3V supply to sensors, modulesDo not exceed 3.3V
GNDPowerGroundConnect to all circuits for reference
EN (RST)ControlResetPull low to reset ESP32
VINPowerInput voltage (5–12V)Feeds internal regulator
GPIO 0DigitalBoot mode / general purposeLOW at boot = flash mode
GPIO 1 (TX0)UARTSerial TXAvoid using for programming
GPIO 3 (RX0)UARTSerial RXAvoid using for programming
GPIO 2DigitalLED / general I/OHas internal pull-up
GPIO 4DigitalRelay / sensorSafe for outputs
GPIO 5DigitalRelay / LEDStandard digital I/O
GPIO 12DigitalSPI / outputBoot-sensitive
GPIO 13DigitalSPI / outputCan drive LEDs or relays
GPIO 14DigitalSPI / outputSafe for outputs
GPIO 15DigitalSPI / inputBoot-sensitive
GPIO 16, 17DigitalUART / outputSafe for general I/O
GPIO 18–23DigitalSPI / I2C / outputMulti-purpose, can drive relays
GPIO 25–27Digital / ADC / DACPWM / analog outputDAC pins for analog signals
GPIO 32–39Digital / ADCSensor inputs / analog3.3V max, input only for 34–39
VP (GPIO 36), VN (GPIO 39)AnalogADC channelsInput-only, no pull-up
SDIO / SPI PinsDigitalSD card / SPIShared functions with other GPIOs
SCL / SDAI2CSensor communicationDefault I2C pins (GPIO 22 = SCL, GPIO 21 = SDA)

Notes:

  • PWM: Any GPIO except input-only pins can be used for PWM (relay control, LEDs).

  • ADC: GPIOs 32–39 for analog sensors.

  • Boot-sensitive Pins: GPIO 0, 2, 12, 15 – avoid driving high during boot unless intentional.

  • Relay/Output Control: Use GPIO 4, 5, 16, 17 for safe switching.

  • Voltage Limits: ESP32 GPIO pins are 3.3V max. Never exceed.

ESP32 Pinout


Circuit Diagram Explanation

The circuit allows the ESP32 to control 4 separate outputs safely through relays using optocouplers.

  • ESP32 GPIOs → connected to BC547 transistors through 1K resistors.

  • BC547 → drives the PC817 optocoupler to isolate the microcontroller from high voltage.

  • PC817 output → controls the 6V relay, which switches the home appliances.

  • Diodes (1N4007) → connected across relay coils to prevent back EMF damage.

  • LEDs → indicate the ON/OFF state of each relay.

  • 7805 Regulator → provides a stable 5V supply to ESP32 if using a higher voltage DC source.

This configuration ensures that the ESP32 is protected while safely switching higher voltage devices.

Download Circuit Diagram

ESP32 IoT Home Automation Project
10/14/2025

Step-by-Step Build Guide

Step 1.

First, mount the ESP32 on the breadboard or PCB and ensure its 5V and GND are properly connected.

Step 2.

Connect each GPIO pin (for example, GPIO 5, 18, 19, 21) to the base of BC547 through a 1K resistor.

Step 3.

Connect the collector of each BC547 transistor to the anode of PC817 optocoupler LED input. Connect the cathode to GND.

Step 4.

Connect the PC817 phototransistor output: collector goes to the relay’s input pin, emitter to GND.

Step 5.

Place 1N4007 diodes across each relay coil (cathode to +V, anode to coil pin) to protect against back EMF.

Step 6.

Connect LEDs with 1K resistors in series across each relay output to indicate the ON/OFF state.

Step 7.

Connect 3-pin terminals to relay outputs for connecting home appliances.

Step 8.

Power the ESP32 with 5V via 7805 regulator if using a 12V supply.

Step 9.

Upload the ESP32 code for WiFi control (using Blynk or a web server interface). Test each GPIO to ensure it switches the respective relay.


Applications

  • Home automation for lights, fans, and small appliances.

  • IoT-based energy management.

  • Remote control through smartphones or PC.

  • Smart home integration with sensors or voice assistants.


FAQs

Q1: Can I control appliances more than 6A using this setup?
A1: No, relays used here are 6V, typically rated for 5-10A. For higher current, use relays with higher ratings.

Q2: Can I use ESP8266 instead of ESP32?
A2: Yes, but ESP32 is preferred for multiple GPIOs and stable WiFi connection.

Q3: Do I need external power for relays?
A3: Yes, a 6V DC supply for relays is recommended; ESP32 cannot drive relays directly.

Q4: Can I use this system for AC appliances?
A4: Yes, but ensure proper isolation and use relays rated for AC voltage.

Q5: How do I control via smartphone?
A5: Use a Blynk app, or program ESP32 as a web server to control GPIOs over WiFi.


Conclusion

This ESP32 IoT Home Automation Project is a safe, reliable way to control 4 devices remotely. By combining ESP32, relays, optocouplers, and transistors, the system provides electrical isolation and clear visual feedback through LEDs. You can expand it further by adding sensors or integrating with voice assistants for a complete smart home experience.

Leave a Reply

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