Say if I had one GPIO pin. Could I connect it to another pin on a different Pi and have it pick up the first pin's signal as input? Would I need to connect both Pi's ground pins to each other?


It can be done several ways. You can connect GPIO pins as simple IO, or use the pins with UART capabilities for a serial connection (essentially like using a null modem), or use the pins with I2C capabilities for a master-slave serial bus arrangement. I'm sure there are other methods as well.

For a simple GPIO example, you could cable the 2 RPis directly together as you've described, with a pin designated as output on one RPi fed to another pin designated as input on the other RPi. The problem is that this is only unidirectional, so only good for letting one RPi know of a condition, and not any sort of response. Any given pin can be configured as either input or output, and won't have any way of automatically switching between modes without some extra work. If you want bi-directional communications, you'll need a second set of pins for traffic going the other way.

Always be aware that the RPi GPIO pins operate at 3.3v. Be careful if introducing other devices that might work at higher voltages. Also be cautious if using long copper cable runs if the RPis are on different grounds. At any sort of distance, a direct copper cable may not be your best option. You might want to use isolators or some circuit protection if doing anything complex. If you need distance between the RPis, network communications might be simpler.

tl; dr: Yes, it can be done. It may not be simple, but you need to expand on what you're trying to do to say for sure.

  • 1
    To elaborate, I was interested in hooking up multiple Pi's to one Pi. I was working on creating a simple model of the internet, using two or more Pi's. Dec 15 '17 at 21:16
  • 2
    In that case, i2c is probably too limited. Using GPIO pins directly, you're going to end up requiring 2 pins per RPi. You also need to consider your topology. Will all the RPis connect to one as a hub-and-spoke, or some sort of partial mesh? Are you trying to emulate the "early days" of the Internet, or just work with protocols?
    – bobstro
    Dec 15 '17 at 21:42
  • I was trying to emulate the early days(but using a custom framework of my own design) I was also planning on using three pins for each connection(one for upload, one for download, and one for a tick timer to keep everything in sync). As for the system, it will both, kind of. Think of it as a binary tree, with the servers and clients on the bottom, and the intermittent bits(which I'm calling the tree) in the middle. Sorry for the late comment. :) Dec 18 '17 at 16:41
  • It sounds interesting, but this sounds more like "pre-internet". You're basically creating a serial point-to-point connection between each RPi. You will likely need to add a ground line. With the clock line, you're creating a synchronous serial link, so you have TX, RX, CLK and GND. However, this approach was largely abandoned in favor of async serial, and those protocols are well established. Your "intermittent bits" sound like serial concentrators/terminal servers, essentially emulating the POTS that was used for dial-up. How faithful to the actual early Internet are you trying to be?
    – bobstro
    Dec 18 '17 at 17:25
  • Well, not very faithful, this was more of a challenge for me to create a networked situation from the ground up(even with converting messages to binary and sending those messages in binary). And I didn't quite get this in your answer, but do I need to connect the grounds? Dec 18 '17 at 17:34

Yes, you can connect a Pi GPIO to another Pi's GPIO.

As you say you do also need to connect the grounds (so they both agree about the levels).

One GPIO should be set as an output, the other should be set as an input.

(If both are incorrectly set as outputs with one high and one low that becomes a possibly damaging short circuit).

  • Is there a good link to information on the maximum practical cable lengths for this sort of connection between devices?
    – bobstro
    Dec 15 '17 at 15:52
  • @bobstro Not that I am aware of. However CAT5 cable for Ethernet makes 100 metre segments so of that order I expect. Presumably 3V3 will limit the distance compared to 5V.
    – joan
    Dec 15 '17 at 16:26

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.