Recommended Free Tools
You can switch a relay from a browser on the same Wi-Fi network using an ESP8266-01, but the ESP-01 must not power a relay coil directly. Use a relay board with a transistor or MOSFET driver and suppression diode, power the ESP-01 from a regulated 3.3 V supply, and check the board’s GPIO assignment and active polarity before wiring. This guide covers both a bare ESP-01 with a separate relay module and an integrated ESP-01 relay carrier; their wiring is not interchangeable.
Identify your ESP-01 relay hardware
“ESP8266-01 relay module” can refer to two different builds. A bare ESP-01 is a small Wi-Fi module that needs a separate relay driver and suitable power. An ESP-01 relay carrier has a socket for the ESP-01 and an onboard relay, but its pin assignment, input voltage, and switching polarity depend on the specific board.
As an Amazon Associate I earn from qualifying purchases.
| Hardware | What to check | Trade-off |
|---|---|---|
| Bare ESP-01 plus separate relay module | Driver transistor or MOSFET, coil suppression diode, coil voltage, 3.3 V logic compatibility, and whether isolation is genuine | More wiring, but easier to inspect and replace parts |
| ESP-01 relay carrier | Schematic or pinout, relay GPIO, active polarity, input-voltage requirements, onboard regulator, boot behavior, and terminal spacing | Compact and convenient, but board designs vary and may be poorly documented |
Do not assume a carrier accepts 5 V just because a particular model has an onboard regulator. Do not assume it uses GPIO2 or that its relay is active-low. A 2024 Silicon Chip review of compact Wi-Fi relay modules describes a design using GPIO0 and active-low transistor switching, and warns that some compact boards lack adequate separation for direct mains switching. Check your own board’s documentation before choosing a pin or connecting a load.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →What the relay switches—and what its terminals mean
A relay uses a low-voltage control signal to move electrical contacts. On a typical single-pole relay, COM is the moving common contact, NO (Normally Open) is disconnected from COM when the relay is idle, and NC (Normally Closed) is connected to COM when the relay is idle. For a first test, use an LED with a suitable resistor, a small DC lamp, or another isolated low-voltage load.
#1 Best Overall
- Based on ESP-01S module.
- This module uses ESP-01S as the main control and is remotely controlled by mobile phone APP for smart home or IOT projects.
- With this smart relay, you can easy to DIY your smart switch and control any device through your phone anywhere.
- Light weight, compact size and very easy to install in a small case.
- Package Includes: 5Set ESP8266 Transceiver + Relay Switch Board
A relay input can be active-high or active-low. With active-high control, a HIGH signal energizes the relay; with active-low control, LOW energizes it. The input’s polarity is a property of the relay board, not a universal ESP-01 convention. Confirm it with the load disconnected.
Power and GPIO requirements
Supply the ESP-01 with regulated 3.3 V
The ESP8266EX operating-voltage range is 2.5–3.6 V; a bare ESP-01 must not be connected directly to 5 V. Espressif’s ESP8266 hardware-startup guidance recommends a 3.3 V supply capable of at least 500 mA for ESP8266 modules. That capacity matters because Wi-Fi transmission can create short, high-current demands even though the datasheet’s average operating-current figure is around 80 mA. A weak supply can cause resets, failed uploads, Wi-Fi dropouts, or relay chatter.
Place a 10 µF capacitor and a 0.1 µF ceramic capacitor near the ESP-01’s supply pins if appropriate for your build. These can help with local supply transients, but they do not replace a properly rated regulator. Keep supply wires short. If the relay uses a separate coil supply, follow the relay module’s instructions; for a non-isolated driver, connect the ESP and relay grounds.
Do not drive a relay coil from a GPIO
ESP8266 GPIO pins are 3.3 V logic outputs, not coil power sources. The ESP8266EX datasheet specifies a maximum GPIO current of 12 mA, and a relay coil is an inductive load that normally requires more current. Use a relay module with a transistor or MOSFET driver and flyback diode, or build a suitable driver stage with a switching transistor or logic-level N-channel MOSFET. For a bare DC coil, place a flyback diode across the coil with its cathode toward the positive supply and its anode toward the transistor-switched side. A relay board with an onboard driver and diode does not need a second diode added across the coil.
Rank #2
- 3V Relay Module: Working Voltage: DC 3-3.3V; Working Current: 65mA; Trigger Current: 3mA;Load: 10A 250VAC / 10A 30VDC;Load Current: 10A max
- Optocoupler Isolator: 3V/3.3V Power Relay Module Supports Photocoupler Isolation Control
- High Level Trigger: The Relay Module is Triggered by High Level Signal, Which Can Be Input From Microcontroller IO
- Jumper Caps: By Removing the Jumper Caps on the Pins,You can Select Whether the Relay and the Signal Share the Same Power Supply or Not,But We Are Recommended to Share the Same Power Supply
- Wide Application: These 3V Relay Power Switch Module Works Well With ARM /PIC /AVR /MCU/Raspberry/CNC machine/ PS4/3.3V /NodeMCU/ ESP8266 Module etc.
A module described as a “5 V relay” may need 5 V for its coil while accepting a 3.3 V control signal, but that is board-specific. Verify its input threshold and wiring rather than treating the relay’s coil voltage as the ESP-01’s supply voltage.
Choose a GPIO with boot behavior in mind
The standard ESP-01 exposes GPIO0 and GPIO2 as convenient general-purpose pins, but both affect startup. GPIO0 must be high for normal boot and low to enter serial programming mode. GPIO2 must be high at boot. GPIO1/TX and GPIO3/RX serve the UART and can produce serial activity during startup, making them poor quiet relay outputs unless the circuit accounts for that behavior. GPIO15 is another boot-strap pin, but it is generally not exposed on the standard ESP-01 header. Espressif documents the boot pins in the ESP8266EX datasheet; the ESP8266 Arduino Core board documentation also notes that pins 0, 2, and 15 are checked at boot.
The example below uses GPIO2 only when the relay driver leaves it high during reset and its startup behavior is acceptable. A carrier board’s schematic takes precedence over generic advice: if the carrier uses GPIO0, for example, the software pin must match that design, and the relay circuit must not prevent normal boot or uploading.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Wire a bare ESP-01 and relay module
For the ESP-01 itself, connect the following before adding the relay module. EN is also labeled CH_PD or CHIP_EN on some boards; it must be high for the chip to operate and must not float. Espressif’s startup guidance explains this enable-pin requirement.
Rank #3
- Relay supports Normally Open and Normally Closed
- Relay supports High-level Trigger or Low-Level Trigger selectable by a jumper
- Relay with Optocoupler Isolation
- Relay with Terminal Blocks for both Input and Output Interface
- Relay with two LED Indicators: power (green LED), the relay status (red LED)
| ESP-01 pin | Normal-operation connection |
|---|---|
| VCC | Regulated 3.3 V |
| GND | Ground |
| EN/CH_PD | 3.3 V through a pull-up; do not leave floating |
| RST | 3.3 V through a pull-up; an optional momentary button can connect it to GND |
| GPIO0 | 3.3 V through a pull-up; keep high during normal operation |
| GPIO2 | Relay-driver input only if the driver preserves the required boot state |
| TX | USB-serial adapter RX, if serial monitoring is used |
| RX | USB-serial adapter TX, if serial monitoring is used |
Connect the relay module’s control input to the selected GPIO and supply its coil from the voltage specified by its documentation. A non-isolated driver needs a shared ground with the ESP-01. If the relay module has genuine optocoupler isolation, use the board’s isolation wiring instructions instead of automatically tying the two sides together; an optocoupler alone does not guarantee safe isolation if the board layout or wiring defeats it.
For an ESP-01 carrier, use its documented input supply and relay pinout instead of applying the bare-module wiring table to its terminals. Some carriers regulate their input down to 3.3 V; others require a different supply arrangement. Confirm the relay coil voltage, GPIO, polarity, and behavior during reset before connecting the ESP-01 or a load.
Prepare the USB-to-serial connection and upload mode
Use a USB-to-serial adapter with 3.3 V UART logic. A 5 V logic adapter must not be connected directly to the ESP-01 UART; the Arduino core’s board documentation warns against using a 5 V adapter without suitable level conversion. The adapter’s 3.3 V output is suitable as the ESP supply only if it can provide adequate current for Wi-Fi peaks.
Free tools Windows power users keep installed
One-click scans. No signup required.
- Connect adapter GND to ESP-01 GND.
- Connect adapter TX to ESP-01 RX and adapter RX to ESP-01 TX.
- Connect a suitable 3.3 V supply to VCC and keep EN/CH_PD high.
- Pull GPIO0 to GND, then reset or power-cycle the ESP-01 to enter the serial bootloader.
- Upload the sketch using the correct serial port and board configuration in the Arduino IDE.
- After upload, disconnect GPIO0 from GND and reset or power-cycle again for normal execution.
If a carrier’s relay circuit or other components interfere with GPIO0 or the UART, disconnect the carrier while uploading if the board design permits it. Avoid guessing at a menu path or board-package version: the Arduino IDE interface and core releases can change.
Rank #4
- This module uses genuine relays and normally open interfaces. High stability and low power consumption.
- Strong driving ability, stable and reliable performance. High efficiency, fine workmanship, and durable.
- Add one more ESP-01S module. This smart relay module is based on the ESP-01S WIFI module design. It can be used to DIY your own smart switch. It can be remotely controlled by the mobile phone APP and provides APP and LUA source programs. It's easy to use right away.
- The package includes:2 pcs ESP8266 ESP-01S Relay module, relay WIFI smart socket (with ESP-01S)
- We are very grateful for all customers’ opinions to improve sales, if you are not satisfied, please contact us to find the best solution
Upload a local Wi-Fi relay sketch
This example starts a basic HTTP server on port 80. Enter your 2.4 GHz Wi-Fi network name and password, then confirm that GPIO2 and the active polarity match your hardware. It is an unauthenticated LAN demonstration, not a secure remote-control system.
#include <ESP8266WiFi.h>
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
const uint8_t RELAY_PIN = 2; // GPIO2; verify your board schematic
const bool RELAY_ACTIVE_LOW = true;
WiFiServer server(80);
void setRelay(bool on) {
bool level = RELAY_ACTIVE_LOW ? !on : on;
digitalWrite(RELAY_PIN, level ? HIGH : LOW);
}
bool relayIsOn() {
int level = digitalRead(RELAY_PIN);
return RELAY_ACTIVE_LOW ? (level == LOW) : (level == HIGH);
}
void setup() {
// Set the safe inactive level before enabling the output.
digitalWrite(RELAY_PIN, RELAY_ACTIVE_LOW ? HIGH : LOW);
pinMode(RELAY_PIN, OUTPUT);
setRelay(false);
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Open http://");
Serial.print(WiFi.localIP());
Serial.println("/");
server.begin();
}
void loop() {
WiFiClient client = server.available();
if (!client) {
return;
}
client.setTimeout(1000);
String request = client.readStringUntil('r');
client.flush();
if (request.indexOf("GET /on") >= 0) {
setRelay(true);
} else if (request.indexOf("GET /off") >= 0) {
setRelay(false);
}
bool on = relayIsOn();
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html; charset=utf-8");
client.println("Connection: close");
client.println();
client.println("<!doctype html><html><body>");
client.println("<h1>ESP8266 Relay</h1>");
client.print("<p>Relay: ");
client.print(on ? "ON" : "OFF");
client.println("</p>");
client.println("<p><a href="/on">Turn on</a></p>");
client.println("<p><a href="/off">Turn off</a></p>");
client.println("</body></html>");
delay(1);
client.stop();
}
The RELAY_PIN value must match the GPIO actually connected to the driver, and RELAY_ACTIVE_LOW must match the relay board. The sketch sets the requested inactive output level before enabling the pin, but software cannot prevent every startup pulse caused by hardware pin states. Design the driver so its default state is safe.
This server has no authentication or encryption, does not persist relay state after reset, and has no fail-safe timeout or production-grade request validation. Use it only on a trusted local network; do not port-forward it directly to the public Internet.
Test the relay before connecting a load
- Leave the relay contacts disconnected from the intended load and power the ESP-01 and relay board.
- Open the serial monitor at 115200 baud and wait for the printed local IP address.
- From a device on the same Wi-Fi network, open that IP address in a browser.
- Use the Turn on and Turn off links. Confirm the relay click and, if present, the module indicator LED.
- If the behavior is reversed, change
RELAY_ACTIVE_LOWand upload again. - After the low-voltage test succeeds, connect the intended load only if the relay, wiring, terminals, and enclosure are suitable for it.
Troubleshoot by symptom
| Symptom | Checks and remedies |
|---|---|
| Upload fails or the ESP will not enter normal boot | For uploading, hold GPIO0 low before reset; for normal execution, remove that connection. Check that GPIO2 is not forced low, EN/CH_PD is high, UART lines are crossed, adapter logic is 3.3 V, and the supply can handle current peaks. Disconnect a carrier if its circuitry interferes with boot pins or UART. |
| Boot loop, resets, or corrupted serial output | Suspect a weak 3.3 V regulator, long or thin supply wires, or relay-coil noise. Use a regulated supply capable of at least 500 mA, shorten supply wiring, add local capacitors, and separate the relay coil supply where appropriate. A non-isolated driver still needs common ground. |
| Relay turns on during reset | Boot and UART pins can have defined or transient states during startup. Use a driver whose default is off, choose a compatible exposed GPIO, or redesign the pull-up/pull-down arrangement. Do not add a resistor blindly: it might stop the ESP from booting or entering programming mode. |
| Relay does not trigger, or works backward | Check the GPIO assignment and active-high/active-low setting, coil supply, input threshold, output configuration, and ground connection. An optocoupler input may need more current than the GPIO can provide. Measure the relay input and coil supply instead of relying only on an indicator LED. |
| No Wi-Fi connection or browser access | Check the credentials, serial output, signal strength, and router client-isolation settings. ESP8266EX Wi-Fi operates in the 2.4–2.5 GHz range, according to the ESP8266EX datasheet. The sample waits for a connection and does not implement reconnection; a more robust build should add nonblocking reconnection and account for DHCP address changes. |
| Relay clicks but the load stays off | Check whether the load is wired through COM and the intended NO or NC contact, whether its power supply and fuse are intact, and whether contact voltage/current ratings suit the load. Motor, transformer, compressor, and LED-driver inrush can stress contacts more than a resistive lamp. |
Choose a control method that fits the project
For a first demonstration, local HTTP is easy to test in a browser. For home automation, MQTT can publish and receive state through a broker, but it adds configuration and requires access control and preferably TLS on untrusted networks. Cloud or mobile platforms can simplify remote access while adding account, service, network, and policy dependencies. None is necessary for a basic local relay demonstration.
Best Value
- ✔Based on ESP-01S WIFI module.
- ✔Designed for smart home,internet and other DIY projects.
- ✔With this smart relay, you will easy to DIY your smart switch to control any device by your phone anywhere.Providing APP and LUA source programs. It can be controlled remotely
- ✔Light weight, compact size and very easy to install in a small case
- ✔Package Includes: 3 Set ESP8266 Transceiver + Relay Switch Board
If you need USB programming, more GPIO, easier debugging, or more robust onboard power regulation, a NodeMCU- or Wemos D1 mini-class ESP8266 development board is usually simpler than a bare ESP-01. Use an ESP-01 when its small size or compatibility with an existing carrier matters. For household loads, a certified enclosed smart relay or smart plug is a safer alternative to designing an exposed mains circuit.
Keep mains switching within safe limits
Do not wire mains on a breadboard. De-energize circuits before changing relay wiring; enclose exposed terminals; use suitable wire, fuses, strain relief, and enclosure materials; and maintain safe separation between mains and low-voltage circuitry. A relay’s printed contact rating does not certify the complete carrier board, its PCB spacing, enclosure, or user protection. The Silicon Chip review cited above specifically cautions that some compact ESP-01 relay boards may not maintain sufficient separation for direct mains switching.
For household AC, use a certified enclosed relay product, an appropriately listed external relay, or qualified professional assistance rather than relying on an inexpensive bare carrier. If switching any inductive or high-inrush load, select contacts and suppression for that load rather than treating a headline current rating as universal.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




