Synchronization Functions

Hi, I’m working on a project that requires multiple Particle devices to execute functions with fairly precise synchronization. Are there any libraries or tricks to ensure that code across multiple devices all get executed at the same time?

I’ve pondered this for a synchronized lighting display made up of multiple photons that needed as close to millisecond synch as I could get. The method I came up with was to send commands to the all the photons using UDP multicast. The Photons would parse those commands and then wait for a “go” signal. After a short delay (to ensure each Photon completed the parsing), the controller would send a very short “go” command packet, again via UDP multicast, which would signal to all the Photons to start their lighting sequence. I haven’t tested this control method yet. I only built the one prototype so I don’t yet have a “swarm” of lighting pods to control.

Of course UDP multicast is a best effort protocol and does not guarantee delivery. So you should take measures to put the devices on a segregated VLAN or something to ensure UDP works well.

There may be some other methods such as using IR beacons but then you need line-of-sight and external components.

If you need less accurate means, you could use Time and make sure you do a Particle.synchTime() periodically to minimize drift.

2 Likes