Automatic dusk-to-dawn light
Lights switch on by themselves at dusk and off again in the morning.
Shop by category
Shop all componentsThe ESP-01S relay board is a ready-made socket for an ESP-01S: 5 V in, the ESP8266 drives the relay from GPIO0. The sketch starts a small web server with ON and OFF buttons. Program the ESP-01S in the USB downloader, then plug it onto the relay board. Start with a 12 V lamp or fan; mains loads need a proper enclosure and an electrician.
Anything connected to 230 V mains must be installed by a qualified electrician in a closed, earthed enclosure. Test with a low-voltage lamp first.
Tick anything you already have and the total updates.
Programs the ESP-01S
Follow the colours: red is power, dark grey is ground, blue is a signal.
12 V adapter for the lamp; buck module makes 5 V for the relay board.
esp01s_relay.inoVerify & upload in Electrolark#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char* SSID = "your-wifi";
const char* PASS = "your-password";
const int RELAY = 0; // GPIO0 on the ESP-01S relay board
const bool ON_LEVEL = LOW; // most boards switch on with LOW; change to HIGH if yours is reversed
ESP8266WebServer server(80);
bool on = false;
void setRelay(bool v) { on = v; digitalWrite(RELAY, v ? ON_LEVEL : !ON_LEVEL); }
void page() {
String h = "<meta name=viewport content='width=device-width'><h2>Lamp is ";
h += on ? "ON" : "OFF";
h += "</h2><a href=/on><button style='font-size:2em'>ON</button></a> <a href=/off><button style='font-size:2em'>OFF</button></a>";
server.send(200, "text/html", h);
}
void setup() {
Serial.begin(115200);
pinMode(RELAY, OUTPUT);
setRelay(false);
WiFi.begin(SSID, PASS);
while (WiFi.status() != WL_CONNECTED) delay(250);
Serial.println(WiFi.localIP());
server.on("/", page);
server.on("/on", [] { setRelay(true); page(); });
server.on("/off", [] { setRelay(false); page(); });
server.begin();
}
void loop() { server.handleClient(); }
GPIO0 is a boot pin; a short click at start is normal on this board.
Change ON_LEVEL to HIGH.
The module must be in download mode (GPIO0 low at power-up); use the switch on the downloader.
Only through a proper enclosure installed by an electrician; test with 12 V first.
Yes with extra libraries, but keep it local first.
It is the improved ESP-01 with 1 MB flash and pull-ups on the board.
5 parts: AI-Thinker ESP-01S ESP8266 WiFi Module, ESP8266 ESP-01S WiFi Relay Module w/ 10A Relay, ESP8266 ESP-01/01S USB Downloader w/ CH9102F & Auto-Download Circuit, DC Power Adapter (5.5x2.1mm) and Step-Down Converter to 5V USB / 5V 3A. On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 1 hour. The build on this page has 5 steps.
No. This page has the complete, tested code (esp01s_relay.ino).
About ₹745 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Programming an ESP-01S with a USB adapter; A tiny ESP8266 web server; Active-low relay control.
Anything connected to 230 V mains must be installed by a qualified electrician in a closed, earthed enclosure. Test with a low-voltage lamp first.
Lights switch on by themselves at dusk and off again in the morning.
A precise thermostat that keeps tropical fish at a steady 25–26 °C.
Starts the pump when the tank runs low and stops it when it is full.
Tap a hidden pad to switch a lamp on or off, even through a wooden desk.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.