0

I'm trying to use my laptop to instruct multiple raspberry pi's to take a picture simultaneously.

I have a DHCP LAN network which connects to my laptop and raspberry pi through ethernet cables. I've assigned a static IP to my laptop (192.168.0.1) and to my raspberry pis (192.168.0.2) and (192.168.0.3)

How can I get my Raspberry Pi's to immediately execute a "listening" Python script upon startups waiting for prompts from my laptop to take these pictures? What script can I use from my laptop to instruct these pi's to take a picture?

Not sure if this would come in handy but my Pis are installed with Raspbian and my laptop with Windows 10.

  • so, are you asking, how do you start a python program on boot? – Jaromanda X Jan 8 at 11:25
  • You have DHCP but use static addresses? Then DHCP seems irrelevant to the question. – Thomas Weller Jan 8 at 11:30
  • Does this answer your question? what is the easiest way to trigger an event on 3 Pis at the same time – joan Jan 8 at 11:54
  • Sorry I might have misunderstood the meaning of DHCP. I'm using a LAN device where I connect all computers to it through ethernet cables. Currently accessing the raspberry pi's through SSH. Yes. How do I start a python program on boot? Do you guys by chance know how to code a python script that accepts manual input from an external device? – Rogash Jan 8 at 12:08
1

How simultaneously do you need it to be? If "within a couple of seconds" is fine, then just call your scripts sequentially via SSH:

sshpass -p 'raspberry' ssh pi@192.168.0.2 python take_photo.py &
sshpass -p 'raspberry' ssh pi@192.168.0.3 python take_photo.py &

You may want to setup a passwordless login to make the commands simpler.

If you need to be even faster (hundreds of milliseconds), you can keep the SSH sessions open and send commands to such open sessions:

#log in via SSH (using sshpass or manually)
sshpass -p 'raspberry' ssh pi@192.168.0.2 &
sshpass -p 'raspberry' ssh pi@192.168.0.3 &

# take note which PTS files got created

#later on from a script
echo python take_photo.py > /dev/pts/1
echo python take_photo.py > /dev/pts/2

For an even faster response, ditch the network entirely and wire a trigger signal to the GPIO. Any "python script that accepts manual input from an external device" you'll write will likely be just as slow as SSH is.

| 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.