Power-status lamp

An LED ring that shows green when power is on, red when it is off, and amber for a scheduled outage window.

Smart home Board: ESP32-C3 SuperMini Level: ●○○ ⏱ 1 h

A lamp that shows the state of somewhere else

A lamp that goes red when the power is off cannot work in the same place: it would be off too. The idea becomes interesting when it shows the state of another place, such as your parents’ house, the dacha or the office. A small node there connects to an MQTT broker and declares a "last will" message. When its power vanishes, the broker publishes the message and the lamp turns red.

Build notes

The WS2812 ring needs 5 V, a 330 Ω resistor in the data line, and a large capacitor on the supply. A 3.3 V data signal usually works, but a level shifter is safer.

  • Use animation as well as colour: a slow pulse for "off", steady for "on", so it is readable for people who confuse red and green.
  • Dim it at night by the clock.
  • A schedule of planned outages can be a third colour, amber, if you have a trustworthy source for it; unofficial APIs can change without notice.

Components

  • ESP32-C3 SuperMini
  • WS2812B LED ring / strip (addressable)
  • Dupont jumper wires (M-F, M-M)
  • USB charger 5V 2A

Wiring

Module Module pin ESP32 pin Note
WS2812 ring DIN data GPIO4 330 Ω in series, 1000 µF across 5V/GND
WS2812 5V / GND 5V / GND USB charger 5V 2A for the whole lamp

Libraries

  • Adafruit NeoPixel

Code

#include <WiFi.h>

const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASS = "YOUR_PASSWORD";

bool connectWiFi(uint32_t timeoutMs = 20000) {
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  uint32_t t0 = millis();
  while (WiFi.status() != WL_CONNECTED && millis() - t0 < timeoutMs) {
    delay(250);
    Serial.print(".");
  }
  Serial.println();
  if (WiFi.status() == WL_CONNECTED) {
    Serial.print("IP: ");
    Serial.println(WiFi.localIP());
    return true;
  }
  return false;
}
#include <HTTPClient.h>
#include <WiFiClientSecure.h>
#include <Adafruit_NeoPixel.h>

const char* STATE_URL = "http://192.168.1.10:8123/local/power-state.json";   // YOUR source: JSON like {"state":"on"} / "off" / "maybe"
const int PIN_LED = 4, N_LED = 16;
Adafruit_NeoPixel ring(N_LED, PIN_LED, NEO_GRB + NEO_KHZ800);
String state = "unknown";

void showAll(uint8_t r, uint8_t g, uint8_t b) { for (int i = 0; i < N_LED; i++) ring.setPixelColor(i, ring.Color(r, g, b)); ring.show(); }

bool fetchState() {
  HTTPClient http; WiFiClientSecure sec; sec.setInsecure();
  bool ok = String(STATE_URL).startsWith("https") ? http.begin(sec, STATE_URL) : http.begin(STATE_URL);
  if (!ok) return false;
  int code = http.GET(); String body = code == 200 ? http.getString() : "";
  http.end();
  if (code != 200) return false;
  if (body.indexOf(""on"") >= 0) state = "on"; else if (body.indexOf(""off"") >= 0) state = "off"; else if (body.indexOf(""maybe"") >= 0) state = "maybe"; else return false;
  return true;
}
void setup() {
  Serial.begin(115200); ring.begin(); ring.setBrightness(40); showAll(0, 0, 40);
  connectWiFi();
}
void loop() {
  static uint32_t t = 0;
  if (t == 0 || millis() - t > 30000) {
    t = millis(); if (WiFi.status() != WL_CONNECTED) connectWiFi(8000);
    if (!fetchState()) state = "unknown";
  }
  if (state == "on") showAll(0, 120, 0);
  else if (state == "off") showAll(140, 0, 0);
  else if (state == "maybe") showAll(140, 70, 0);
  else showAll(0, 0, 60);                       // blue: no data
  delay(500);
}

Build tips

  • Publish the JSON from Home Assistant, a small web service or your own scraper; the lamp only reads it.
  • If the source disappears the lamp turns blue so you never see a stale green.

What you need

Buy the parts kit · Estimated total: $11.00

ESP32-C3 SuperMini × 1
$2.50
Buy at AliExpress Buy at Amazon.com
WS2812B LED ring / strip (addressable) × 1
$3.00
Buy at AliExpress Buy at Amazon.com
Dupont jumper wires (M-F, M-M) × 1
$1.50
Buy at AliExpress Buy at Amazon.com
USB charger 5V 2A × 1
$4.00
Buy at AliExpress Buy at Amazon.com
🇺🇦 Ukraine🌍 Other countries

Other countries: order these parts on AliExpress with the links below.

Some links are affiliate links: we may earn a commission at no extra cost to you.

Related ideas

⚠ Caution

Switch only low-voltage loads yourself. For mains loads use a certified isolated module in a box or call an electrician.

Router and Starlink watchdog

Pings the internet and power-cycles the router or ONU through a relay when the connection hangs, with a Telegram notice.

  • Board ESP32-C3 SuperMini
  • Level ●○○ Beginner
  • Build time 1 h
Pick parts / kit
⚠ Caution

Switch only low-voltage loads yourself. For mains loads use a certified isolated module in a box or call an electrician.

Gate and garage door status with remote pulse

Two reed switches report open and closed, a relay gives the opener a pulse, and a message tells you when the gate was left open.

  • Board ESP32-C3 SuperMini
  • Level ●○○ Beginner
  • Build time 1–2 h
Pick parts / kit

WLED lighting on an ESP32

Addressable LED strips and rings with effects, scenes and a phone app, running the ready-made WLED firmware, plus a clean power layout so they do not flicker.

  • Board ESP32-C3 SuperMini
  • Level ●○○ Beginner
  • Build time 1–2 h
Pick parts / kit

← All module ideas →

Comments

No comments yet. Share your experience or ask a question.

Comments are moderated.