Sat, 30 Jan 2021 13:46:06 +0000
There are probably better ways to satisfy the need for a wall light than
- cutting up a 150 LED Neopixel strip, sticking the pieces to a piece of aluminum, then soldering wires from each row to the next
- building a ESP8226 circuit on stripboard to drive it
- sending 10x15 arrays of RGB over MQTT to specify colours
The led strip came from my Christmas lights, as did the circuit - now transferred from breadboard to a more permanent soldered stripboard. The Arduino sketch, known as Dolores ("do lo-res") is all new, though, and parts of it (the bits that are plain C++ not Arduino code) are even unit-tested.
Perhaps worth noting
- 10x15 pixels with a byte each for R G B is 450 bytes of data, which is more than the default max packet size of the Arduino MQTT library I'm using. Fix this with a call to
client.setBufferSizewith a more appropriate value
- after the first time I'd put it all together and installed it on the wall, I realised that software updates were going to be considerable faff, given they require unplugging the Wemos D1 from its circuit and attaching it to USB. OTA updates to the rescue! This makes the device run a HTTP server which new images can be POSTed to. There are better ways to do this - I'd rather it were an HTTP client which fetched images from a known URL, instead of accepting anything from anyone that can reach its port 80 - but that can wait until I have some kind of CI setup.
- the Nix environment I'm using for Arduino IDE only works with
nix-build. I'd like it to behave as a regular derivation so I can have a CI setup
But now I can send it any picture I like. Here's a digital clock -
while sleep 2 ; do \ ( convert -support .5 -depth 8 -fill red \ -font DejaVu-Sans-Condensed -pointsize 7 -size 15x10! \ -draw "text 0,7 '$(date +%H%M)'" -sharpen 8 'xc:#333' RGB:- | \ tee out.rgb | \ nix run nixos.mosquitto -c mosquitto_pub -h mymqttserver.lan \ -s --username username --pw password \ -t effects/84F3EBE5E57C/image ) ; \ done