A custom snowfall effect for a programmable LED strip, running on an ESP32 and controlled from my phone.
I wanted LED lights that looked like snow falling, and nothing on the market did it the way I pictured. So I built my own: a programmable strip, an ESP32, and a control page on my phone, with no app or cloud account needed.
It only works with programmable LED strips (I used WS2812B). Each LED on those has its own tiny chip, so every one can be a different color, and that’s what makes effects like rainbow possible. A regular RGB strip changes all its LEDs together and needs different wiring. The ESP32 does everything else. It joins my Wi-Fi, serves the control page, and drives the LEDs. Picking a color on the page sends a small request to the board, and the firmware redraws the strip about 60 times a second.
The snow, falling
for (Flake& f : flakes) {
if (!f.active) continue;
f.pos -= f.speed;
// Fell off the bottom: free this slot for a new flake.
if (f.pos < 0) {
f.active = false;
continue;
}
// Split the flake across two LEDs so it glides instead of jumping.
int i = (int)f.pos;
uint8_t below = (uint8_t)(255 * (1.0f - (f.pos - i)));
leds[i] += CRGB(SNOW_WHITE).nscale8_video(below);
if (i + 1 < NUM_LEDS) leds[i + 1] += CRGB(SNOW_WHITE).nscale8_video(255 - below);
}
A flake between two LEDs lights both, in proportion. That’s what makes it glide.
I powered the strip from the ESP32’s 5V pin instead of adding a separate power supply. That’s fine for a short strip, but the 5V pin comes straight from USB, which only gives about 500 mA. Thirty LEDs on full white can ask for 1.8 A. Instead of adding hardware, I capped it in code: FastLED dims the whole strip if a color would draw more than 450 mA.
The power cap
// Strip runs off USB through the ESP32, // so keep total draw under USB's ~500 mA #define MAX_MILLIAMPS 450 FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); FastLED.setMaxPowerInVoltsAndMilliamps(5, MAX_MILLIAMPS);
A mini version of the control page. The column of dots stands in for the strip.