Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsOpenWeatherMap offers a free tier that returns the weather for any city as JSON. The ESP32 asks for it every ten minutes with your own API key, parses the reply with ArduinoJson and shows the city, temperature, humidity and description on an OLED. This is the forecast service's reading for your city, not a measurement from your room. Keep your API key private, and note that new keys can take a little while to start working.
Tick anything you already have and the total updates.
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB phone charger.
weather_oled.inoVerify & upload in Electrolark#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>
const char* SSID = "YOUR_WIFI";
const char* PASS = "YOUR_PASSWORD";
const char* API_KEY = "YOUR_OPENWEATHERMAP_KEY";
const char* CITY = "Bengaluru,IN";
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
void show(const char* a, const char* b, const char* c) {
oled.clearDisplay(); oled.setTextColor(WHITE); oled.setTextSize(1);
oled.setCursor(0, 0); oled.print(a);
oled.setTextSize(2); oled.setCursor(0, 16); oled.print(b);
oled.setTextSize(1); oled.setCursor(0, 44); oled.print(c);
oled.display();
}
void fetchWeather() {
WiFiClientSecure client;
client.setInsecure();
HTTPClient http;
String url = String("https://api.openweathermap.org/data/2.5/weather?q=") + CITY + "&units=metric&appid=" + API_KEY;
http.begin(client, url);
int code = http.GET();
if (code == 200) {
JsonDocument doc;
deserializeJson(doc, http.getString());
String temp = String((float)doc["main"]["temp"], 1) + " C";
String line3 = String((const char*)doc["weather"][0]["description"]) + " " + String((int)doc["main"]["humidity"]) + "%";
show(CITY, temp.c_str(), line3.c_str());
} else {
show("Weather error", String(code).c_str(), "check key and city");
}
http.end();
}
void setup() {
Wire.begin(21, 22);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
show("Connecting", "", "");
WiFi.begin(SSID, PASS);
while (WiFi.status() != WL_CONNECTED) delay(300);
}
void loop() {
fetchWeather();
delay(10UL * 60UL * 1000UL);
}
The API key is wrong or not yet active. New keys can take some time.
The city name was not found. Use the format City,CountryCode.
Check the OLED wiring and that Wi-Fi connected.
OpenWeatherMap has a free tier with call limits. Check their current terms.
No. It is the service's reading for your city.
Yes, with their forecast endpoint and a bigger display.
4 parts: ESP32-WROOM-32 38-Pin Development Board, 0.96" OLED Display 128x64, Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 1.5 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (weather_oled.ino).
About ₹595 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Making an HTTPS request from the ESP32; Parsing JSON with ArduinoJson; Using a free weather API key.
Ideas that reuse this build: ESP32 OLED internet clock. They are listed under Take it further on this page.
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Press to roll: the pips tumble and slow down before landing on a number.
Wait for the light, hit the button: how many milliseconds can you beat?
A bright 4-digit clock that keeps time through power cuts.
Learning project. Check every circuit and the datasheet of each part before you power it up.