-1

Depending on usage frequency, may get the occasional collision where both test for availability at the same time - if occurring too frequently, maybe add something simple like one arduino only does time updates on even seconds, the other on odd seconds.

https://forum.arduino.cc/index.php?topic=64049.0

I need events executed in the multiple receiving Arduino's to occur in sync (simultaneously). Is there a library or something, probably using the ESP32's RTC, to ensure events occur in sync?

Example system:

  • ESP32 sender/master
  • Arduino1 receiver controlling LEDs (Christmas lights)
  • Arduino2 receiver controlling stepper motors (Mary figure)
  • Arduino3 receiver controlling stepper motors (Joseph figure)

The issue is that they are sent data at different times by the user.

Say, the user selects settings for Mary. That data is sent to the ESP32, and then that data is sent to all the Arduinos, but only "gets into" the MaryArduino.

Then, the user selects settings for the lights. That data is sent to the ESP32, and then data is sent to all the Arduinos, but only "gets into the LightsAruino.

Etc.

However, I need everything to start at the same time.

The data is not simultaneously sent. It is sent one after the other, as slow as the user selects their settings. However, the sequence of events must simultaneously occur.

17
  • 1
    moving an actuator, turning on a light, running a stepper motor a number of steps, etc. Commented Feb 22, 2021 at 20:02
  • 1
    Events need to happen at specific times: Think of a light show synchronized to music. Commented Feb 22, 2021 at 20:24
  • 1
    light synchronized to music is not an example of simultaneous events, as far as the microcontroller is concerned ... it only has to look synchronized to a human ... a microcontroller can go on vacation between two events and the two events would still look simultaneous to a human Commented Feb 22, 2021 at 20:28
  • 1
    @adamaero You can connect serial in parallel, ironically. if your high-level protocol allows all nodes to get the same broadcast, typically by each having an ID/tag it's "interested" in ala wifi/i2c, there's no real limit. If each line has to transmit different messages, then you can still easily do a dozen or two with an ESP32, since you only need TXs and it has a whole dang bunch of pins ;) Commented Feb 22, 2021 at 21:26
  • 1
    then just wire all the slave RXs together to the master's TX, and then send away. With a message format like "MARY=1;RED=1", at 57k baud, mary and the red light will turn on at the same time (fraction of a ms), even to a high-speed camera, much less a human. Commented Feb 22, 2021 at 21:34

1 Answer 1

1

Give the master a single signal wire that is connected to all of the slaves and that signal LOW while the master sends commands to each slave. Let each of the slave Arduinos simply store its message but not act on it while the signal wire is LOW.

When the slaves are supposed to start, raise the signal level to HIGH. Each slave Arduino now executes whatever command it had been sent. The RTC now only needs to be connected to the Master, which controls all of the timing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.