I am totally new to Pi and networking in general and have no clue where to look for guides.

I need to build a system in which one master Pi controls several slave Pis. And those slave Pis are sending real-time data back to master Pi from sensor readings. The master Pi and slave Pis are likely to be connected over a dedicated network (wireless).

1) Switches are connected to the master and when a switch is turned on, it should automatically send some commands to a slave Pi (like to tell it to light up a LED connected to one of its GPIO pins). How can I do that? The idea in my head is to have master Pi SSH into that particular slave Pi but how do I automate the process of sending a prefixed command when triggered by a switch?

2) What methods/protocols should I use to send and receive real-time data from sensor readings of slave Pis? How do I do that? Will I need SFTP/SCP/SSHFS/FTP etc?

3) These 2 processes described above need to be applied to all slave Pis. Am I able to simultaneously do these on all slave Pis from the master Pi? Or do I have to switch from controlling one slave Pi to another? How do I do that?

Thank you :)

3 Answers 3


To add to @Milliways answer.

pigpio is a perfect fit for this type of application (I am the author so treat what I say with normal scepticism).

A piece of software called pigpiod needs to be running on each Pi.

pigpiod allows control of the Pi's GPIO locally or from over the network. pigpiod uses a socket interface which is supported by all programming languages. Wrappers for Python and C/C++ are provided.

Python scripts are probably the easiest interface. The controlling script(s) may be on a Pi or any other machine capable of running Python. E.g. Windows, Macs, Linux, Android etc. The script can control its own GPIO (if running on a Pi) as well as any other Pis.

gpiozero provides a wrapper around pigpio (as well as other Python GPIO libraries) and has a wealth of resources.

  • I was thinking more like each slave Pi has its own program script. So I would like that pushing a button on the master Pi launches a command on the slave Pi's script. How can I do this?
    – pomeloyou
    Dec 7, 2017 at 17:26

You should probably be using sockets to communicate.

The pigpio library has socket interfaces to GPIO and has plenty of examples.

Your question is too general to give a more specific answer.


If you are looking to use networked communications I highly recommend a messaging system like MQTT (a good one for the Pi is Mosquitto). And here's a good instruction set on how to install it on the Pi.

Please note that the instructions call for using the Debian Wheezy repository, which is now out of date. Replace "wheezy" with whichever version of Debian/Raspbian you are using. As of the time of this answer, the latest is "stretch".

Essentially your master pi runs the broker, and the others run clients that publish data to the broker. They can also subscribe to the broker if they need to accept data and/or instructions from it. It's basically up to you how you use it because you configure the topic hierarchy and it just sends whatever you give it to/from the broker.

Using MQTT can result in single-digit millisecond-level communication speeds, even on Wifi. If you need faster than that, you should probably be looking at custom GPIO communications like @Milliways mentions in his answer.

I hope this helps!

Your Answer

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

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