Christmas RGB Animation with ESP-GO

Chrismas lights

My ESP8266 home control code ESP-GO doesn’t get a lot of attention in here as I’m a “Tasmota” fanatic but that does not mean that ESP-GO is dead – far from it. ESP-GO contains not only RGB code for serial 5v LEDs but also a complete programming setup to generate and loop sequences… and so with merely one wire and VERY  little work, we end up with some fancy animation. Add that and another, simpler display to a load of more conventional Christmas lighting and….

Animated lights

I wrote the original version of the code for this beautiful Christmas decoration in December 2017 – when we lived in a different house with a completely different WIFI setup and of course I put this gadget in the loft and forgot all about transferring the Node-Red code across to the new house Raspberry Pi (at the time I was a little busy having an ischaemic stroke). So today when I powered up the ESP12 and nothing happened I got very close to throwing the lot in the bin. As I had an hour to spare (there is an issue with the present development release of Tasmota so I’m having a half-day break to avoid frustration) I put an FTDI on the generic ESP12 board (inside the decoration) and put in my current WiFi and MQTT credentials.

The only things that changed were WiFi ssid and pass, along with the IP address of my local MQTT broker. Thankfully all else remained the same. Thank heavens for the blog.  I’ve made tiny changes to the Node-Red function to reflect a more modern way of using global variables – otherwise this is the 2017 project and it works a TREAT..

Above you see an old, gutted plastic Christmas window decoration which WAS originally filled with pretty grim, old fashioned white lights but now has a string comprising a 94 (5v) serial LED string running animation around the inside.

For anyone using my ESP-GO software and wanting to knock up a quick Christmas animation – here it is…

My code lets you refer to a string of RGB lights – up to 300 of them and do things like:  make the first 10 LEDs RED and pause them for a second, then make the second 20 LEDs GREEN and wait for 5 seconds, clear the lot, wait 1 second. 

That sequence will then continue  forever in a loop – and that’s just a trivial example – here in THIS decoration I set up a nice colourful display (the actual plastic unit is white – no colour at all and the cat has nothing to do with anything but in 2019 she’s still here, still needy and still keeps us up at night).

Non-animated lights

The top unit is now INCOMPATIBLE with  pre-2017 code so if you have something already running from 2016 when I FIRST wrote about ESP8266-sequenced Chrismas lights, you’ll need to add a new first parameter (1) to keep compatibility.

Here is how to make a Christmas ornament as in the candle light above with sequencing yellow-white-blue-ish tips…

if (msg.payload=="reset") .global.set("stepper",0); 
var steps=[
"{rgbadd:1,30,6,255,255,0,200}" ];
return msg;
Node-Red Flow

In the node-Red code above, I wait for the ESP21 board to login as usual – and when it does I sent it a sequence of instructions, once, which will set up the display. Once set the code will do nothing more. Purple nodes are MQTT talking to the display unit which is called “xmas”

That function that says “Continue until end of array is merely this..

if (msg.payload!==undefined) return msg;

I’ve also included an “inject” mode for manual testing. It merely sends out text with the word “reset” in the payload.

Looking at the list above, the first command stops anything already running. The second sets up 94 LEDs on GPIO12 (count is the second parameter).

An example of a simple light up is the third instruction – code 1, from LED 8, light  up 15 LEDs in RED (255,0,0) for 5ms.

The other instructions are the same, lighting up segments of the display for X amount of time, I do the tips of the candles in white, wait a while then change them to yellow – the rest of the display is static – of course one could be a HELL of a lot cleverer than that. This is all noted in the WORD document for the ESP-GO code on BitBucket.

There is also a command 4 which means END – you’d only use that if you wanted to perform a series of loops and then stop permanently. That has no parameters.

Assuming you’ve used the latter and have a sequence which does whatever and then stops – it might be nice to store this in FLASH and recall it when needed. There are four non-volatile buffers available to store this information.

{rgbstore:X} where X is 0-3

You can play back any of these as below, again assuming in this case GPIO12 and 12 LEDs. Set X to be 0-3


The above will play back a stored sequence immediately.

The code is in the usual place and available via the OTA. See Home Control blog.

As you can imagine – you could set up a LOT of this stuff as the code is only sent out once.  Limits are 1 strip of up to 300 RGB serial LEDs per ESP8266.

Now all we need are a few hundred ordinary lights and the tree…

The tree

6 thoughts on “Christmas RGB Animation with ESP-GO

  1. I might have missed something but I needed to make some changes to make this work. The “Continue to end of array” function needed this:
    if (msg.payload===undefined) msg.payload=”reset”;
    return msg;

    … while the “check for powerup” needed this:
    if (msg.payload==”powerup”) {msg.payload=”reset”; return msg;}


  2. My bad, I didn’t understand how the Home Control code was supposed to work and a faulty series of lights didn’t help. With new LED lights, the original code works well.

    Didn’t help that I was powering the ESP12 AND the lights from the USB socket on my lappy so I could send commands via YAT (a nice find by the way).

    Thanks Peter.

    1. Perhaps one for you to look at next year, but WLED flashed onto an ESP2866 Dev board makes a brilliant controller for RGB LED strips. I haven’t used it’s MQTT integration but I did control about 1000 LEDs (from a single Dev board) using Xlights/XScheduler to send it E1.31 commands. It can control far more than a thousand LEDs but I ran out of time to build more! XScheduler also works with MQTT so I could synchronise the turning on of static lights as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.