Build it step by step
0 of 8 doneWire the ring
Test it with a simple colour fill.
Find your coordinates
Look them up on a map and fill in the placeholders.
Fill in Wi-Fi
Replace the placeholders.
Upload
The lamp shows a colour within a few seconds.
Compare with a weather app
Check it agrees.
Test the offline case
Turn the router off and see the soft white.
Test the mapping
Temporarily force each mood in the code.
Fit a diffuser
Put it in a lamp body.
How do you build a weather-colour lamp?
A lamp glows blue for rain, orange for heat and white for clear sky, using a free weather API. You need ESP32 DevKit V1, WS2812B ring 16 LEDs, 5 V 2 A USB adapter and Resistor 330 Ω. It takes 8 steps and about 90 minutes.
- Level
- Intermediate
- Time
- About 90 min
- Parts
- 4
Parts list
- Development BoardsBuyESP32 DevKit V1 × 1
- OptoelectronicsBuy
- PowerBuy
- PassivesBuyResistor 330 Ω × 1
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| 5 V supply + | LED ring VCC and ESP32 VIN | Power |
| 5 V supply - | LED ring GND and ESP32 GND | Common ground |
| ESP32 GPIO5 | 330 Ω resistor then ring DIN | Data line |
Code
Open-Meteo is a free weather service that needs no account or key; put your own latitude and longitude in the placeholders. The sketch asks for the current temperature, rain and weather code every 30 minutes, which is polite and enough. Rain, drizzle, snow or storms pulse blue; 35 degrees or more is orange; 28 or more is warm yellow; otherwise soft white. If the network or the service is down, the lamp falls back to a calm soft white so it never goes dark. setInsecure() skips certificate checking, which is acceptable for public weather data but is not safe for anything private. Put the ring behind a frosted diffuser such as a jar or lampshade. Arduino IDE with the ESP32 boards package, board "ESP32 Dev Module".
Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Libraries: Adafruit NeoPixel, ArduinoJson. Uses the free Open-Meteo API, which needs no key.
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <Adafruit_NeoPixel.h>
const char* WIFI_SSID = "YOUR_WIFI_NAME";
const char* WIFI_PASS = "YOUR_WIFI_PASSWORD";
const char* LATITUDE = "YOUR_LATITUDE"; // for example 12.97 for Bengaluru
const char* LONGITUDE = "YOUR_LONGITUDE";
Adafruit_NeoPixel ring(16, 5, NEO_GRB + NEO_KHZ800);
enum Mood { OFFLINE, CLEAR, RAIN, HOT, WARM };
Mood mood = OFFLINE;
unsigned long lastFetch = 0;
void fetchWeather() {
WiFiClientSecure client;
client.setInsecure(); // skips certificate checking: fine for public weather, not for private data
HTTPClient http;
String url = String("https://api.open-meteo.com/v1/forecast?latitude=") + LATITUDE + "&longitude=" + LONGITUDE +
"¤t=temperature_2m,precipitation,weather_code";
if (!http.begin(client, url) || http.GET() != 200) { mood = OFFLINE; http.end(); return; }
JsonDocument doc;
if (deserializeJson(doc, http.getString())) { mood = OFFLINE; http.end(); return; }
http.end();
float temp = doc["current"]["temperature_2m"];
float rain = doc["current"]["precipitation"];
int code = doc["current"]["weather_code"];
if (rain > 0 || code >= 51) mood = RAIN; // codes from 51 up are drizzle, rain, snow and storms
else if (temp >= 35) mood = HOT;
else if (temp >= 28) mood = WARM;
else mood = CLEAR;
}
void fill(uint32_t c) { for (int i = 0; i < 16; i++) ring.setPixelColor(i, c); ring.show(); }
void setup() {
ring.begin(); ring.setBrightness(60);
WiFi.begin(WIFI_SSID, WIFI_PASS);
unsigned long t = millis();
while (WiFi.status() != WL_CONNECTED && millis() - t < 15000) delay(300);
}
void loop() {
if (lastFetch == 0 || millis() - lastFetch > 1800000UL) { lastFetch = millis(); if (WiFi.status() == WL_CONNECTED) fetchWeather(); else mood = OFFLINE; }
float pulse = (sin(millis() / 1200.0) + 1) / 2; // slow pulse from 0 to 1
switch (mood) {
case RAIN: fill(ring.Color(0, 0, 40 + 150 * pulse)); break; // pulsing blue
case HOT: fill(ring.Color(255, 90, 0)); break; // orange
case WARM: fill(ring.Color(255, 160, 40)); break; // warm yellow
case CLEAR: fill(ring.Color(220, 220, 200)); break; // soft white
default: fill(ring.Color(120, 100, 80)); break; // offline: soft white
}
delay(40);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Rain | Slow pulsing blue |
| 35 degrees or more | Orange |
| Clear and mild | Soft white |
| Network down | Soft white, no crash |
If it does not work
Always soft white
Check Wi-Fi, the coordinates and that the service responds.
Wrong colour
Check temperature thresholds in the code.
Colours wrong
Try NEO_RGB.
Flicker
Check the common ground and supply.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the weather-colour lamp?
ESP32 DevKit V1, WS2812B ring 16 LEDs, 5 V 2 A USB adapter and Resistor 330 Ω.
How long does the weather-colour lamp take to build?
About 90 minutes for a intermediate maker, in 8 steps.
How do I know the weather-colour lamp works?
Rain: Slow pulsing blue. 35 degrees or more: Orange. Clear and mild: Soft white.
Always soft white: what should I check?
Check Wi-Fi, the coordinates and that the service responds.
Wrong colour: what should I check?
Check temperature thresholds in the code.
Colours wrong: what should I check?
Try NEO_RGB.
Flicker: what should I check?
Check the common ground and supply.
