ArrowtronElectronics Store
Free shipping over ₹999
100% genuine components
Dispatch in 1–2 days
Secure payments · UPI, Cards

WiFi Smart Relay: Control Any Appliance from Your Phone (ESP8266)

Build your own smart switch: an ESP8266 hosts a tiny web server so you can toggle a relay — and whatever is connected to it — from any phone or laptop on your network.

Intermediate~60 minutes4 components

What you’ll build

A WiFi-controlled switch. The ESP8266 NodeMCU connects to your home WiFi and exposes simple /on and /off web endpoints that switch the 5V relay module, letting you control a connected appliance remotely.

Components you’ll need

ComponentQtyPrice
ESP8266 NodeMCU V3 WiFi Development Board1₹199
5V Single Channel Relay Module for Arduino1₹49
830 Point Solderless Breadboard Full Size1₹99
Male to Female Jumper Wires 40pcs 20cm Multicolour1₹49
Total₹396

Step-by-step guide

  1. Mount the ESP8266 NodeMCU on the breadboard and power the rails from its 3V3 and GND pins.
  2. Connect the relay module: VCC to Vin (5V), GND to GND, and IN to GPIO5 (D1).
  3. Keep the mains/appliance wiring for later — first test the relay with just the low-voltage side.
  4. In the Arduino IDE, install the ESP8266 board package and select NodeMCU 1.0 as the board.
  5. Edit the sketch with your WiFi name and password, then upload it.
  6. Open the Serial Monitor to find the ESP8266 IP address, then visit http://THAT-IP/on and /off from your phone to switch the relay.

The code

This sketch connects to WiFi and serves two endpoints that switch the relay on and off.

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char* ssid="YOUR_WIFI"; const char* pass="YOUR_PASS";
ESP8266WebServer server(80); const int relay=5;
void setup(){ pinMode(relay,OUTPUT); WiFi.begin(ssid,pass);
  server.on("/on",[](){digitalWrite(relay,HIGH);server.send(200,"text/plain","ON");});
  server.on("/off",[](){digitalWrite(relay,LOW);server.send(200,"text/plain","OFF");});
  server.begin(); }
void loop(){ server.handleClient(); }

Build this project

Add all 4 required components to your cart in one click — total ₹396.

Add all components to cart
Scroll to Top