Hiya! Does anyone have any good info on wirelessly syncing multiple controllers (ModeMCU ESP8266)

Hiya!

Does anyone have any good info on wirelessly syncing multiple controllers (ModeMCU ESP8266) together? My current plan is to use MQTT.

I am starting a new project with around 1200+ SK9822 LEDs (strip 30/m). I am breaking those LED strips into 7 modules that will all be identical. Each module will contain around 180 LEDs and will be controlled by an ESP8266 running the FastLED library (and a few others).

I am planning to run something like a web server to provide the input, logic, and possibly coordination/instructions to the ESPs. The idea is that the modules should act as one large matrix (in 3D space) that will be easier to control from the server side (and eventually an app). Furthermore, not all modules may be used at once and so any coordination/syncing will need to be flexible to accommodate anywhere from 2 to possibly 10+ modules (if I choose to expand the project).

The overall syncing of the controllers is actually quite important. For the first prototype I just need to convince the human eye that they syncing is simultaneous, but in the future it would be great to have the syncing have a tolerance of less that 1/2000 of a second (ideally as simultaneous as possible).

I actually haven’t used FastLED before and so I am not sure if MQTT would even be feasible (and honestly I already know that the protocol is pretty crap for what I need, but I need to start somewhere and it is what I know). My backup plan is to connect the modules together with wires and have one ESP8266 control the whole matrix, but this approach severely limits the value proposition of my project.

Any other details that I need to provide? Any recommendations greatly appreciated!

If you’re looking for that level of syncing then you are probably going to want to abandon the idea of streaming the animations between devices.

Instead have all devices be capable of generating the same animations based off a few minimal settings. Then sync the devices by emitting a multicast UDP packet from a central device which then is received by all devices. The packet should be as small as possible, contain a sequence number to identify misordered packets and carry the minimal settings you need to key the state of the animation. This allows then for a very fast packet to be sent out, you do not need to wait for TCP overhead from the central source and you can manage any number of devices without having to open and establish connections to them as they come in and out of range.

How you encode the state of your animations is up to you and very dependent on what you are trying to achieve. Probably best though to have your animations be generated from a seed value, and then periodically synchronize the seed values on the devices with the packets. If you fix the frame rate on each device and update the seed at a fixed interval you should be able to achieve reasonable sync.

Awesome sauce. Thank you for the detailed response @Ben_Delarre ! Just for my own understanding, can anyone point me to some projects where multiple controllers were synced or working cooperatively regardless of the protocol used? After digging in the G+ group I have found some projects that stated they synced multiple controllers, but gave no details on how they did it. (ie https://plus.google.com/u/2/118380100409228041640/posts/5vsA4n7WPWv)

Can be done but with lots of details that need looked at. Here is a project I did a few years ago https://www.instagram.com/p/BPoH4K8lW3o/ it had 10 x esp8266 each driving a string of 100 x WS2801. The inside crustal sohere had 1 x esp8622 with about 900 x SK9822 pixels. All thr animations were streamed from another esp8266 all connected together with a high end wifi router. There are a few ways to do this. Iether code up your micro to be an artnet receiver and trasnmit animation data using glediator/resolume/madmapper etcc any vj suite. Or code up your own animation protocol using MULTICAST UDP. Take note not to use Unicast or broadcast because both are desigbed to be unreliable. Multicast is designed to be rebroadvast by the router. Make sure you have a really high quiality wifi router. And if u want higher performnace go with the esp32 or rpi/nanopi/any linux soc

@Leon_Yuhanov Agreed you can indeed go the multicast udp packets containing all your animation frames. I found that I got a lot of dropouts and missed frames in ‘noisy’ environments which meant that my various devices would glitch. And by ‘noisy’ i’m talking clubs full of people with mobile phones.

In general I found unless you can strictly control the environment then wifi is inherently unreliable. If you’re trying to stream the full frame data this becomes very noticeable to humans quite quickly, the bandwidth also limits your frame rate substantially. So making each of the devices independent gives you a bit more reliability in your animations, but it does certainly complicate the programming.

@Leon_Yuhanov the Crystal Disco Cave looks great btw!

@Ben_Delarre thanks Ben. I had dropped frames as well. End of the day the esp8266 is limited in power. Im working on a huge project at the moment, using 30+ nanopi (rpi clones) with a few hundred pixels on each. Driving them via wifi, 0 dropouts!

Thank you @Ben_Delarre and @Leon_Yuhanov ! The disco cave does look amazing! It sounds like you both have quite a bit of experience and some of that was over my head. I should have preceded my question by saying that my project is not related to venue lighting and I have zero knowledge/experience with any VJ software. I also do not have a concrete understanding of “animation frames” or “full frame data” in this context.

So a few questions to followup;

  1. @Ben_Delarre what exactly do you mean by “making each of the devices independent gives you a bit more reliability in your animations”. I am mostly unclear on what “independent” means

  2. When you say that the ESP8266 is limited are you talking about the clock speed, flash memory, or something else? What advantage does the ESP32 have in this context? (i already ordered a few)

  3. Are there any open source projects you can point me to that use UDP to control LEDs on multiple ESP8266’s? Being able to review and learn from actual code would be very helpful in this case. I have a lot to learn obviously…

@Garrett https://github.com/leonyuhanov/esp8266_ws2801_node have a look at this its one of the nodes that drives 100 pixels. I cant post the trasnmitter cose though.
The esp8266 uses its cpu to run your code and the wifi code. Its limited in perfomance the esp32 has 2 cores way faster

@Garrett it sounds like you are still pretty early days with your investigations. I would recommend you start simple and work your way up. Maybe take a look at the Adafruit learning system they have an interesting project called Lightship which does wireless LEDs https://learn.adafruit.com/lightship-led-animation-over-wifi/overview

The ESP32 is a whole other level of complication, and while it might have better wifi performance it will make your code a lot more complex to fully take advantage of its dual core system.

I’m not sure what your experience level is with C/C++ so you might want to start with the basics and work your way up.

Wealth of information here, thanks.

If you’re going to use MQTT, then you’re designing around each node running its animations. You’ll then send strategic messages from a central controller (e.g. “run animation A with colorpalette B with settings X,Y,Z”) and possibly a sync message.

The arrival of the sync message will not be perfectly timed, and it may be systematically biased (a Node is always the 11th to get contacted by the broker).

I might look at putting an RTP server on your router and then each node can periodically pull a good value for time. Then, each node can sync up at the top of each minute.