Displays
Round weather radio
It looks like an old radio, but its round dial shows today's live weather for your town.
- Medium
- about 45 min
- ESP32-S3
- 5 parts
- 7 wires
- 120 lines of code
- Uses Wi-Fi
ESP32 packs are built on real parts: the simulator runs Arduino Uno circuits only.
Idea
The weather comes from Open-Meteo, a free service that needs no account or key. The board asks a question over the internet and gets back text it has to pick apart.
What you learn
Calling a web API over HTTPS, reading JSON, and drawing round a circle with sine and cosine.
How it works
input
Weather from the internet
decides
ESP32-S3 · Wi-Fi
output
Round screen
Powered with 5 V through the board's USB-C port.
It joins your home Wi-Fi. You type the network name and password into the sketch before uploading; they stay on the board.
A reference design. The sketch is compiled with the real ESP32 toolchain, and its pins are checked against the wiring table automatically. It has not yet been built and tested on real parts by us, so wire it on the bench and run the checks before you build it into a case. Real modules vary: follow the labels printed on yours, not their position in the picture.
Parts
0 of 5 ready
No prices here: they change by shop and by week. Buy each part by its name and the note beside it.
You also need
A computer with Arduino IDE 2 installed (free)
3D wiring
One jumper per step, with the USB cable unplugged. Several wires may share 3V3, 5V or GND: the expansion board or breadboard gives each its own pin.
Step 0 of 7
Lay out the parts
Seat the board on its expansion board or breadboard and lay the modules out round it. Nothing is connected yet.
All connections
weather-radio.ino
// Round weather radio
// The round dial shows the live temperature, humidity and sky for your town.
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_GC9A01A.h>
const char* WIFI_SSID = "YOUR_WIFI_NAME";
const char* WIFI_PASS = "YOUR_WIFI_PASSWORD";
// Your town. These are for Ho Chi Minh City: look yours up on any map.
const float LATITUDE = 10.82;
const float LONGITUDE = 106.63;
const unsigned long REFRESH_MS = 15UL * 60UL * 1000UL;
const int PIN_DIAL_SCL = 12;
const int PIN_DIAL_SDA = 11;
const int PIN_DIAL_DC = 13;
const int PIN_DIAL_CS = 10;
const int PIN_DIAL_RES = 14;
Adafruit_GC9A01A tft(PIN_DIAL_CS, PIN_DIAL_DC, PIN_DIAL_RES);
unsigned long lastFetch = 0;
bool haveData = false;
// Open-Meteo's WMO weather codes, grouped.
const char* skyName(int code) {
if (code == 0) return "Clear";
if (code <= 3) return "Cloudy";
if (code <= 48) return "Fog";
if (code <= 67) return "Rain";
if (code <= 77) return "Snow";
if (code <= 82) return "Showers";
return "Storm";
}
void drawSky(int code) {
const int cx = 120, cy = 78;
if (code == 0) {
tft.fillCircle(cx, cy, 24, GC9A01A_YELLOW);
for (int a = 0; a < 360; a += 45) {
float r = a * DEG_TO_RAD;
tft.drawLine(cx + cos(r) * 30, cy + sin(r) * 30, cx + cos(r) * 40, cy + sin(r) * 40, GC9A01A_YELLOW);
}
return;
}
uint16_t cloud = code <= 3 ? GC9A01A_WHITE : 0x9CD3;
tft.fillCircle(cx - 20, cy + 6, 16, cloud);
tft.fillCircle(cx, cy - 6, 22, cloud);
tft.fillCircle(cx + 22, cy + 6, 16, cloud);
tft.fillRect(cx - 20, cy + 6, 42, 16, cloud);
if (code >= 51) {
for (int i = -1; i <= 1; i++) tft.drawLine(cx + i * 16, cy + 28, cx + i * 16 - 6, cy + 42, GC9A01A_CYAN);
}
}
void draw(float temp, int humidity, int code) {
tft.fillScreen(GC9A01A_BLACK);
tft.drawCircle(120, 120, 118, 0x4208);
// tick marks round the rim, like a radio dial
for (int a = 0; a < 360; a += 15) {
float r = a * DEG_TO_RAD;
tft.drawLine(120 + cos(r) * 110, 120 + sin(r) * 110, 120 + cos(r) * 117, 120 + sin(r) * 117, 0x8410);
}
drawSky(code);
tft.setTextColor(GC9A01A_WHITE);
tft.setTextSize(5);
tft.setCursor(62, 122);
tft.print(temp, 0);
tft.setTextSize(2);
tft.print(" C");
tft.setTextColor(GC9A01A_CYAN);
tft.setCursor(70, 172);
tft.printf("%d%% %s", humidity, skyName(code));
}
bool fetchWeather() {
WiFiClientSecure client;
client.setInsecure();
HTTPClient http;
String url = "https://api.open-meteo.com/v1/forecast?latitude=" + String(LATITUDE, 2) + "&longitude=" + String(LONGITUDE, 2) +
"¤t=temperature_2m,relative_humidity_2m,weather_code";
if (!http.begin(client, url)) return false;
bool ok = false;
if (http.GET() == 200) {
JsonDocument doc;
if (!deserializeJson(doc, http.getString())) {
draw(doc["current"]["temperature_2m"], doc["current"]["relative_humidity_2m"], doc["current"]["weather_code"]);
ok = true;
}
}
http.end();
return ok;
}
void setup() {
SPI.begin(PIN_DIAL_SCL, -1, PIN_DIAL_SDA, PIN_DIAL_CS);
tft.begin();
tft.fillScreen(GC9A01A_BLACK);
tft.setTextColor(GC9A01A_WHITE);
tft.setTextSize(2);
tft.setCursor(70, 112);
tft.print("Wi-Fi...");
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) delay(250);
}
void loop() {
if (!haveData || millis() - lastFetch > REFRESH_MS) {
// Until the first reading arrives, try again every 10 seconds.
if (fetchWeather()) haveData = true;
lastFetch = millis();
if (!haveData) delay(10000);
}
delay(200);
}
Libraries
- ArduinoJson: install it from Sketch > Include Library > Manage Libraries.
- Adafruit GFX Library: install it from Sketch > Include Library > Manage Libraries.
- Adafruit GC9A01A: install it from Sketch > Include Library > Manage Libraries.
Uploading
First time with an ESP32: in Arduino IDE open Boards Manager, search “esp32” and install “esp32 by Espressif Systems”.
- Before uploading, type your Wi-Fi name and password into WIFI_SSID and WIFI_PASS at the top of the sketch.
- Open the sketch in Arduino IDE.
- Plug the board in with the USB-C cable.
- Tools > Board > ESP32S3 Dev Module, then Tools > Port and choose the board's port.
- Press Upload (the arrow). Wait for “Done uploading”.