How-to · Intermediate · 3 min read
Wi-Fi Smart Switches and Relays
Sonoff, Tasmota, ESPHome and ESP8266 Relay Boards
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
Smart switches are Wi-Fi relays that turn lights and appliances on and off. Many use an ESP8266 or ESP32 that can run open firmware such as Tasmota or ESPHome for local control through MQTT or Home Assistant. Choose by relay rating and channels, flash firmware before installation, and have mains wiring done by a qualified electrician.
Key specs at a glance
- Chip
- ESP8266 or ESP32 with a Wi-Fi relay
- Relay rating
- Typically 10 A at 250 V AC; check the device label
- Channels
- 1, 2 or 4 outputs
- Firmware
- Original app, Tasmota or ESPHome
- Integration
- MQTT, HTTP and Home Assistant
- Safety
- Mains wiring is dangerous; use enclosed, certified parts
This part is often wired to 230 V mains. Do all wiring with the plug pulled out, keep mains wires inside a closed box with strain relief, add a fuse, and never touch the board while it is plugged in. If you are new to mains wiring, have an electrician check it before you switch on.
Types of smart relay
Pick the form that suits your installation.
| Type | How it is used | Notes |
|---|---|---|
| Inline switch (Sonoff Basic / Mini) | Behind a wall switch or in a junction box | Small, needs correct neutral and live wiring |
| ESP8266 relay board (1/2/4 channel) | DIY panels and low-voltage loads | Bare board; mount in an enclosure |
| Smart plug | Plugs into a wall socket | Simplest and safest for appliances |
| Hub (Home Assistant Green) | Local controller for all devices | See the MQTT and Home Assistant guide |
- Inline switch (Sonoff Basic / Mini)
- How it is used:
- Behind a wall switch or in a junction box
- Notes:
- Small, needs correct neutral and live wiring
- ESP8266 relay board (1/2/4 channel)
- How it is used:
- DIY panels and low-voltage loads
- Notes:
- Bare board; mount in an enclosure
- Smart plug
- How it is used:
- Plugs into a wall socket
- Notes:
- Simplest and safest for appliances
- Hub (Home Assistant Green)
- How it is used:
- Local controller for all devices
- Notes:
- See the MQTT and Home Assistant guide
Firmware options
Open firmware keeps your devices local, so they work without the cloud. Tasmota has a web interface, templates for hundreds of devices and MQTT. ESPHome compiles firmware from a short YAML file and connects natively to Home Assistant. To flash, connect a USB serial adapter to the programming pads with the board powered from 3.3 V (never while connected to mains), hold the boot pin low and upload. Some devices support over-the-air flashing in DIY mode.
Wiring safely
- Disconnect mains at the breaker before touching any wiring.
- Use devices with an enclosure and the right certification for your region.
- Match the relay rating to the load, and derate for motors and inductive loads.
- Keep low-voltage and mains wiring separated and use strain relief.
- If you are not trained in mains wiring, hire an electrician. See relay modules and SSR vs relay.
Setting up with Home Assistant
- 1Flash Tasmota or ESPHome and connect the device to Wi-Fi.
- 2Configure the MQTT broker address or use the Home Assistant API.
- 3Name the device and the topic.
- 4Add it in Home Assistant and test from a phone.
- 5Set a fixed IP or DHCP reservation so the device is always found.
- 6Add a physical switch input so it works even when Wi-Fi is down.
Try it: Fuse sizing calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Flashing the board while it is connected to mains.
- Exceeding the relay current rating.
- Leaving mains wiring exposed.
- Using weak Wi-Fi signal so the device drops off.
- Skipping a backup of the configuration.
Frequently asked questions
Is Tasmota legal and safe?
Yes. It is open-source firmware. Flashing your own device voids some warranties.
Tasmota or ESPHome?
Tasmota is quick with a web UI. ESPHome suits Home Assistant users who want YAML configuration.
Can the relay drive a motor?
Only within its rating, and motors need extra margin because of start-up current.
Do I need a hub?
Not for Wi-Fi devices, but a hub such as Home Assistant gives automations and dashboards.
Why does the device keep going offline?
Weak Wi-Fi or a poor power supply. Check signal strength and supply.
Parts for this guide
Calculators
Terms in this guide
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.




