Phipps Electronics

Order within the next 

FREE SHIPPING OVER $199

50,000+ ORDERS

WORLDWIDE SHIPPING

SSL SECURED

← Back
You are here:
Print

ESP8266 5V WiFi Relay Board (ESP-01S) – User’s Guide

Overview

This module combines an ESP-01S WiFi microcontroller with a 5V relay, enabling remote switching of AC/DC loads via WiFi. Ideal for IoT, smart home, and automation projects.

  • Relay Rating: 10A @ 250VAC / 30VDC
  • Control Pin: GPIO0 (active LOW)
  • Power Supply: 5V DC (≥250mA)
  • Communication: WiFi (802.11 b/g/n)

What You’ll Need

  • ESP-01S WiFi Module
  • ESP-01 Relay Board
  • USB-to-Serial (FTDI) adapter
  • Jumper wires
  • 5V DC power supply
  • Arduino IDE (or other ESP8266-compatible IDE)

Hardware Setup

Pin Mapping (ESP-01S)

Pin Function
VCC 3.3V power input
GND Ground
RX Serial receive
TX Serial transmit
GPIO0 Relay control (LOW = ON)
GPIO2 General I/O
CH_PD Chip enable (tie to VCC)
RST Reset (optional)

Important: ESP-01S logic is 3.3V. Do not connect RX/TX directly to 5V UART without level shifting.

 

Wiring for Programming

Connect ESP-01S to FTDI adapter:

  • RX ↔ TX
  • TX ↔ RX
  • VCC ↔ 3.3V
  • GND ↔ GND
  • CH_PD ↔ 3.3V
  • GPIO0 ↔ GND (for flashing mode)

Once programmed, plug ESP-01S into the relay board.


Software Setup

1. Install ESP8266 Board in Arduino IDE

  • Go to File > Preferences
  • Add board URL: http://arduino.esp8266.com/stable/package_esp8266com_index.json
  • Install via Boards Manager

2. Sample Code

#include <ESP8266WiFi.h>

const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";

WiFiServer server(80);
int relayPin = 0; // GPIO0

void setup() {
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, HIGH); // Relay OFF
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) delay(500);
  server.begin();
}

void loop() {
  WiFiClient client = server.available();
  if (client) {
    String req = client.readStringUntil('\r');
    client.flush();
    if (req.indexOf("/ON") != -1) digitalWrite(relayPin, LOW);
    if (req.indexOf("/OFF") != -1) digitalWrite(relayPin, HIGH);
    client.print("Relay is now ");
    client.print(digitalRead(relayPin) == LOW ? "ON" : "OFF");
  }
}

Access via browser: http://<ESP_IP>/ON or /OFF


Troubleshooting Tips

Issue Solution
ESP-01S not responding Check 3.3V supply and CH_PD connection
Relay not switching Ensure GPIO0 is driven LOW to activate
Programming fails Confirm GPIO0 is grounded during upload
WiFi not connecting Double-check SSID/password and signal strength

Pro Tips for Integration

  • Use optocoupler isolation if switching high-voltage loads
  • Add flyback diode across relay coil for protection
  • Consider MQTT or Blynk for scalable IoT control
  • Use deep sleep for battery-powered applications (requires GPIO16–RST bridge)

Was this article helpful?
Please Share Your Feedback
How Can We Improve This Article?
Table of Contents
Scroll to Top