I am trying to make a simple stop watch timing system where a Pi at the start of the course would start a timer and then 500m away a second Pi would stop the timer. I have designed a simple scratch project to use gpio pins to start and stop my timer but am unsure how to get the second Pi to trigger my stop command on the first pi. they are connected on a network via fibre optic. so basically need help with sending a stop signal from Pi 2 over the network into scratch on Pi 1.

Any advice/links to similar threads would be appreciated as i am struggling to find the right things when I search :(

  • 1
    all you said is I need to send a signal from one RPi to a second RPi. The two are connected together. .... do you believe that you have provided enough information? .... you did not ask a question – jsotola Mar 4 at 22:08
  • 1
    Does Scratch support remote GPIO? It would be fairly easy in Python. – joan Mar 4 at 22:23

In abstract :

You have 2 Pi's: Starting-Pi and Finish-Pi.

Starting-Pi: Has the trigger mech or button to start the timer and initiate the starting of the timing...

Starting-Pi Sends Signal of 'START' to Finish-Pi, Finish-Pi receives Signal, determines its a 'START' signal, and begins it's timer.

Once payload (runner or racer) reaches the Finish-Pi, you have another Trigger mech and or button to trigger the FINISH signal to the Finish-Pi.

Finish-Pi receives the signal, and stops the timer. Timer value will determine the time it took to run the course.

The biggest hurdle here (no pun intended unless you're running hurdle races), is the sending of the Signal from Starting-Pi to Finish-Pi.

There are quite a few protocols involving a network communication (Signals!) and physical wiring, or even light sensor codes and IR code if you want to go that route.

If you do not have a network, there are wire protocols, you can run wire to tie your two pis together and send signals that way.

If you have a network, you can send signals via HTTP server endpoints, MQTT protocols, Web Sockets, WebRTC, etc etc etc etc....

Many many ways to send that signal.

For starters I find its easy to spin up a python / node / server instance and include appropriate libraries or nodes to send and receive those signals.

Node-red can easily cover all these bases.

You can use this to control GPIO and Wire Protocols.

Hope that helps some.

| improve this answer | |

Fiber optics, 500 meter wiring... this sounds hard.


Perhaps a simpler system would be to:

  1. time sync your two RPis

  2. 'starting line' RPi writes the start time to a file

  3. 'finish line' RPi writes the finish time to a file

  4. Afterwards, you collect the two times & subtract to get course timing.

Some Details:

You've not given us much detail in your question, so this answer will also be sparse.

  1. RPi doesn't have a real-time clock.

  2. If you need accuracy, install ntp clients on both RPis,

  3. If RPis aren't on a network during "the race", there are at least two options, depending upon your accuracy, budget and skill.

3.a. set time on both units "on the bench" before deployment using a command like this:

sudo date -s "Wed Mar 04 18:32:03 UTC 2020"

You'll need to wire up a pushbutton to both RPis & write some code to execute the date -s command at the same time on both units.

3.b. If you read this article, you can decide whether or not the RPI's native timekeeping accuracy is good enough. If it's not, you could purchase a GPS receiver to sync time on each RPi. You can research the details on that, or ask another question.

| improve this answer | |

As you said the two RasPis are connected by a network so you should be able to ping each other and also use ssh. I assume on the start-raspi, where the timer is connected, you have commands to start and stop the timer. For example I will name them mytimer start and mytimer stop. Starting the timer is no problem. You can stop it with the trigger on the stop-raspi by sending an ssh command to the start-raspi:

stop-raspi ~$ ssh login-name@start-raspi 'mytimer stop'

This may have a little delay and it depends on the needed precision but with a fibre optic network it could work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.