Skip to content

Rain radar

Rain is opt-in: nothing is fetched until you choose it. It is in every image except the NM-TV-154’s -esp32-wg one, where it does not fit next to the WireGuard client. On the ESP8266 boards, use the lean image for rain. On the standard image, rain is meant for devices without a heavy theme (see Memory).

Switch Display → Mode to Rain (or tick Rain in the carousel list, unticked by default) and set it up in the Rain tab. The screen becomes a radar scope centred on your location:

  • range rings and a crosshair
  • the radar field in RainViewer’s own Universal Blue colours: light echoes in grey-brown, rain from light to dark blue, then yellow, orange, red and magenta as it gets heavier, and snow in cyan to blue
  • nearby cities as hollow red diamonds, and a green dot for your position
  • on the SmallTV Pro, once you download it, a map under the rain: land, sea, coastlines and borders (see Map under the radar)
  • a timeline at the bottom spanning the last 2 hours

The frames loop as an animation between refreshes, and the whole set refreshes every 15 minutes (10-minute radar steps).

The rain radar scope: heavy rain over Brest in yellow, orange, red and magenta, lighter rain in blue, range rings and crosshair, the city as a green dot with its name, the timeline pill with the -2h/-1h/now labels

The screen (shown at 2×), drawn on a PC by the firmware’s own rain code and display library with real RainViewer frames: a band of heavy rain over Brest, in western France. The simulator that renders it, tools/rain_sim, replays what the device shows once plugged in.

By default the radar is centred on the device location, set in the Display tab’s Clock & night mode card (see Sunrise and sunset brightness). In the Rain tab this is the Use the device location box, which is on by default. While it is on, the radar’s own Latitude and Longitude fields are greyed out. If the device location is still 0/0 (not set), the screen asks you to set a location.

To centre the radar somewhere else, untick Use the device location and enter the latitude and longitude in decimal degrees. The device keeps four decimals, and requests to RainViewer carry only two (see Privacy). The radar’s own coordinates stay saved while the box is on.

  • Range (km) is the outer ring radius, 10 to 100 km. The firmware picks the largest usable image crop for the range at your latitude. At higher latitudes the same range uses a larger source crop, so nothing is lost
  • Refresh (s) is how often the whole frame set is fetched. The default is 900 (15 minutes) and the minimum is 600. A full fetch (the first one, or after a change of location or range) takes about 5 to 6 minutes on the device. The next poll is always scheduled from the end of a fetch, so the device never fetches back to back
  • Animation (s/frame) is how long each frame stays on screen in the loop. The default is 8 seconds

The RainViewer public API serves past radar data only. The timeline runs from two hours ago to the latest frame, labelled -2h, -1h and now, and the current frame’s local time is shown top-right once the clock is synced. The firmware also reads the nowcast frame list, so if the provider serves forecast frames again they will appear on the timeline automatically.

Text & city size scales the overlay texts and the city markers (hollow red diamonds):

  • Small keeps the regular 8 px glyphs and shrinks the markers (3 / 2 px)
  • Medium (default) doubles the main texts (16 px), with 15 / 9 px diamonds
  • Large raises the N and the timeline labels to 24 px and enlarges the diamonds again (20 / 12 px)

On Large the headers and city names stay at 16 px. The built-in font scales only in whole steps, and a 24 px header would cross the scope ring while the longest names would span nearly the whole panel. The RainViewer credit stays small so it never collides with the timeline.

Wind arrow (off by default) draws an arrow under the range, with the wind speed under it. See Wind for how the data is fetched.

  • Wind speed unit follows the distances by default (km/h, or mph with miles), or is set separately: km/h, mph, knots or m/s. The speed is fetched in km/h and converted on the device
  • The arrow points where the wind blows to, which is where the rain is heading: a wind from the north-west (306°) draws an arrow towards the south-east
  • Cloud level uses the wind at 850 hPa (about 1,500 m), the wind that moves the rain clouds. Ground uses the wind 10 m above the ground, which can differ by 30-90° or be nearly calm while the clouds move fast
  • No arrow is drawn under 2 km/h, where the direction has no meaning, or when the last good answer is older than the refresh period plus one hour
  • The data comes from Open-Meteo (CC BY 4.0, no API key), credited in the bottom-left corner while the arrow shows

Nearby cities toggles the reference markers (hollow red diamonds with white labels). The cities of France and Europe are embedded in the firmware from GeoNames cities5000 (CC BY 4.0, also credited in the README), filtered by the range, with the most populous ones labelled.

On the SmallTV Pro the rain can sit on a map: land and sea in dark tones, coastlines and lake shores as thin lines, and country borders dashed. The plane radar shows the same map (see Plane radar). The map is not built into the firmware, so it works anywhere:

  1. Set and save the radar location (and, for the plane radar, its location and range)
  2. In the Rain tab press Download map for the radar location

Your browser downloads three files of Natural Earth 1:10m data (land, lakes and land borders, public domain, about 17 MB) from GitHub, keeps the area within about 175 km of the rain radar’s location, grown to cover the plane radar’s screen when both fit, simplifies it, and uploads a file of a few KB to the device. Your location goes only to the device: GitHub sees three plain file requests. The status line under the button says how big the map is and whether it covers each screen.

The device checks the whole file before it keeps it, then draws each screen’s map once, in that screen’s own projection, and redraws it only when the location or range changes (about 0.2 s). Without a map, or when the map does not cover a screen, that screen looks as before. After a factory reset, a new location or a larger plane radar range, press the button again. Remove map deletes it, and the Map under the radar boxes in the Rain and Radar tabs hide it without deleting it.

The map needs the SmallTV Pro: the ESP8266 boards have no heap to draw it, and the 4 MB ESP32 boards have no flash to spare for it in their update slot, so the button is hidden there. The page fetches the map builder from the device (/rainmap.js) when you press the button, so the boards without the map do not carry it.

Data comes from RainViewer with no API key, under their personal-use terms. Those terms require attribution: the screen credits RainViewer in a corner, and this page names the source. Each device fetches for its own owner. The API is free and its availability is not guaranteed, so RainViewer can change or stop it at any time. If that happens, the screen says Radar data unavailable, with the reason underneath, instead of looping old frames. Frames older than the refresh period plus one hour are never shown.

The image requests go to RainViewer over plain HTTP, so they carry your position rounded to 2 decimals (about 1 km), never the coordinates you entered. The rounding moves the radar picture by at most ~0.5 km, less than one pixel of RainViewer’s image (zoom 7, ~0.8 km per pixel), so no rain detail is lost. At the shortest ranges, where the image is enlarged most, the shift can reach a few screen pixels.

Every refresh, the device fetches the frame list (weather-maps.json) and then a 256 px PNG, centred on your location, for each frame it does not have yet. Frames are stored under their radar time, and consecutive lists share all but one or two frames, so a normal refresh downloads one or two images. Only the first fetch, or a change of location or range, downloads the full set. RainViewer serves radar imagery at zoom 7, and higher zooms return map tiles. The firmware takes the zoom-7 tile, crops the centre to roughly twice the configured range, and upscales it to the full 240×240 screen with bilinear interpolation.

Every frame on screen is shown with its own time. Frames that left the two-hour window are dropped when the new list arrives, and each new frame joins the loop as soon as it is stored. If a download fails partway, the loop keeps the frames it already has (a shorter set, never an older image under a newer time) and a small red dot appears in the corner. The next scheduled refresh fetches what is missing. After a change of location or range, the frames of the old view are not shown again.

Each answer is read under an overall deadline, counted from the end of its headers: 15 s for the frame list (read up to 8 KB, and it is about 0.8 KB) and for the wind, 30 s for a tile. Real answers arrive in well under a second. With the per-byte timeout (httpTimeout) alone, a server that sends a byte now and then could hold the screen and the web page for minutes. Past the deadline the read stops, the status says server too slow, the frames on screen stay, and the next refresh tries again.

The frames live in LittleFS under /rain, 57.6 KB each (64 KB on the ESP8266’s 8 KB blocks). A full set of 13 takes about 800 KB of the ~1 MB filesystem, which also holds config.json and /themes.

  • Every write is checked. A frame that does not fit whole is dropped, never kept truncated
  • A tile is downloaded only when the filesystem has room for it (sized from its Content-Length in whole blocks, or 32 KB when the server sends none) and still keeps 48 KB free for the rest of the firmware, so the radar never fills the disk under a settings save. The download stops at the size it was given room for
  • Installing a theme deletes the rain frames first, so the package gets the space they held. The next refresh downloads them again, around the new theme
  • When room is short, the oldest frames are deleted to make room for newer ones. The loop gets shorter but always ends on the latest radar image (installed themes leave room for fewer frames). Only when that cannot help does the status say storage full
  • /api/status reports the free space seen by the last check (rain.fsFree)
  • The map, once downloaded, is kept outside /rain: the uploaded file /rainmap.dat (at most 41 KB, a few KB for most places) and a 14.4 KB layer for each screen that draws it, /rainmap.bin and /radarmap.bin. An upload needs room for the largest file, both layers and the same 48 KB reserve; when the rain frames hold that room they are deleted first, as for a theme install, and the next refresh fetches them again. Both layers are drawn right after the upload. A layer that cannot be drawn (no memory, no room) is tried again after 10 minutes, or at once after a new location or range. A factory reset removes the map and both layers
  • /rain is created by the first fetch. It is deleted, with everything in it, at the next settings save or boot after rain is turned off (neither the mode nor ticked in the carousel)

The PNGs decode with a decoder written for this firmware instead of a generic library. The tiles use the PNG “None” filter on every row, so the decoder’s sliding window stores one byte per pixel: the pixel’s index in the colour table RainViewer publishes for the scheme (164 RGBA values, rain and snow levels). Radar tiles contain only those values, so this is lossless. It needs 8 KB of heap instead of the 32 KB a full decoder needs, and the result matches a zlib reference decode to the pixel.

Every pixel is premultiplied on black (the screen’s background). After the crop and upscale, each pixel is mapped to the nearest of the scheme’s 149 colours as the RGB565 panel shows them, so the screen renders what RainViewer renders. tools/make_rain_palette.py generates the tables from RainViewer’s CSV. On the ESP8266 the colour lookup is a 32 KB table in flash. On the ESP32 boards, whose app slot is nearly full but whose RAM is plentiful, each decode builds it in a temporary 32 KB buffer instead.

Where the heap cannot give the 8 KB window in one piece (the ESP8266 standard image), the decoder keeps the last 2,048 pixels in RAM and writes older ones to LittleFS in 2 KB segments. It reads them back for the deflate copies that reach further back (about 15 % of copies on real tiles). The frame is byte for byte the same, only slower: about 14-35 s per tile instead of 3 s, for the one or two tiles a poll brings.

With rain off, the radar costs 44 bytes of static RAM on the ESP8266 standard image (its settings and a few pointers). Its state, about 0.3 KB, exists only while rain is in use, and its texts and tables stay in flash.

With rain on, between two refreshes the device holds the times of the frames on screen and the last poll’s diagnostics. During a refresh, the frame list and the HTTP client exist for the whole refresh. The window, the decoder’s state (~4.5 KB in pieces of at most 1.7 KB) and the download and draw buffers exist only for the step that uses them. The window is allocated only after the tile’s download, at the heap peak of a fetch.

The images arrive over plain HTTP from a third party, so the decoder treats them as untrusted. Anything outside the format it supports (another PNG layout, a filter other than “None”, a malformed deflate stream) is refused and the frame is skipped.

The decoder’s cost stays bounded on a hostile tile too:

  • The Huffman tables are built in one pass, and the fixed ones once per decode. A tile made of ~200,000 empty deflate blocks, up to the 256 KB download cap, decodes as fast as a plain one
  • A decode has a 60 s budget. Real tiles take 3 s, or 14-35 s in the small-memory mode, but a tile of short copies that alternate between two stored history segments would reopen a file for each copy, for minutes. Past the budget the tile is skipped and the status says decode too slow, tile skipped. Later refreshes skip that frame without downloading it again, and newer frames still come
  • The decoder calls yield() as it goes, so WiFi and TCP keep running during a decode. On the ESP8266 it yields only while at least 5 KB of heap is free, so the network stack never allocates at the decoder’s heap peak. Below that it feeds the watchdog

The frame list also arrives over plain HTTP, so its values go into a URL only after a check. The tile host must be a rainviewer.com host (no port, no path). Each frame path must start with / and hold only letters, digits, /, _ and -, 64 characters at most (RainViewer’s look like /v2/radar/00ef6bb0bcaf), so a path cannot name another host (@evil.example), a port, a query or a fragment. One bad value rejects the whole list, as a malformed list would, and the frames on screen stay. Redirects are not followed, for the list or the tiles.

The decoder is fuzzed in CI (tests/fuzz, target rain) and compared with a zlib reference decode (tests/rain).

With the wind arrow on, each refresh starts with one request to Open-Meteo (api.open-meteo.com/v1/forecast, the current wind at 850 hPa and at 10 m, in km/h), before the frame list. It goes over plain HTTP like the radar, because the ESP8266 standard image cannot afford the heap peak of a TLS handshake, and it carries the same position rounded to 2 decimals. Both levels come in the same answer, so switching between them needs no new request. Open-Meteo bases its current conditions on 15-minutely model data (API documentation), which matches the default refresh period.

  • The answer is about 0.5 KB with no Content-Length, and is read through a 1 KB cap and the 15 s deadline. Redirects are not followed
  • A direction outside 0-360° or a speed outside 0-500 km/h drops that level
  • A failed request never affects the radar. The last good wind stays on screen until it ages out
  • A change of location drops the wind at once, so the previous place’s arrow is never shown over the new one
  • Turning the arrow on in the settings starts a refresh at once (only the wind and the frame list are fetched when the frames are up to date). If a refresh is already running, the wind request goes between two of its steps

The arrow shows the current wind, also over the older frames of the loop, because the wind now is what tells where the rain goes next. How much the wind turns over the two hours of the loop varies. In one measurement by the author on Open-Meteo’s hourly 850 hPa data for Brest, Paris, Lyon, Strasbourg and Toulouse (24 October to 23 November 2026, hours above 10 km/h), the median change over two hours was about 10°, and it exceeded 30° in about one rain hour in ten (a front or a storm passing).

A decode never takes the free heap under 4 KB (RAIN_DECODE_MIN_HEAP), because the ESP8266 Wi-Fi code does not check its own allocations and crashes when the heap runs that low. The decoder checks once its buffers are allocated, before any work, and at every output row. Under the floor with the 8 KB window, it starts again in the small-memory mode, which needs 6 KB less. If the heap is under the floor there too, the tile is skipped: the frames already on screen stay, the status says low memory, tile skipped with the red dot, and the next refresh tries again.

Measured on an ESP8266 (SmallTV Ultra) during a full fetch of 12 tiles, with the free heap and the largest free block at their lowest:

Image Running with rain At rest Lowest during a fetch
lean rain, ticker (3 symbols) 22.3 KB free, 14.8 KB block 7.1 KB free, 5.9 KB block
standard carousel: ticker (3 symbols), a theme, rain 11.5-12.3 KB free 3.5 KB free, 2.9 KB block

The standard image measurement was taken before the 4 KB floor existed. With a theme and the ticker next to rain, it ran 50 minutes without a reboot, but the decode came close to the Wi-Fi code’s limit. With the floor, the same device skips the tiles it cannot decode safely, and the radar loop gets shorter or stops updating. On the standard image, use rain without a heavy theme, or use the lean image, which has 10 KB more free heap.

The Status tab reports the rain pipeline under rain: how many frames are on disk, whether they are too old to show (stale), the outcome of the last poll (ok, http error, no frames in feed, low memory, tile skipped, decode too slow, tile skipped, server too slow, …), the last HTTP code, the crop size used and the age of the last successful fetch. With the wind arrow on, rain.wind gives the outcome of the last wind request (stage, http, okAgo). While the arrow is on screen (a usable, fresh answer for this location, 2 km/h or more), it also gives the direction the wind comes from (dir, degrees) and its speed (kmh).