---
# System prepended metadata

title: How to connect two Raspberry Pi together?
tags: [Raspberry Pi]

---

There are a few “right” ways to connect two [Raspberry Pis](https://www.ampheo.com/c/raspberry-pi/raspberry-pi-boards)—it depends on whether you want networking, direct file transfer, or one Pi controlling the other. Here are the most useful options.

![maxresdefault (87)](https://hackmd.io/_uploads/HJtJkniNZe.jpg)

**1) Ethernet (best overall: fast + reliable**)
**A) Through a router/switch (simplest)**

* Plug both Pis into the same router/switch (Ethernet or Wi-Fi).
* Find their IPs (router admin page, or on each Pi: hostname -I).
* Connect with SSH:

`ssh pi@<ip-of-other-pi>`

**B) Direct Ethernet cable (no router)**

* [Pi 4](https://www.ampheo.com/search/Pi%204)/5 support auto-MDI/MDIX, so a normal cable usually works (crossover not needed).
* Give each Pi a static IP on the same subnet, e.g.:
  * Pi A: 192.168.50.1
  * Pi B: 192.168.50.2
* Then SSH from one to the other.

**2) Wi-Fi (easy, slower than Ethernet)**

* Put both on the same Wi-Fi network.
* SSH using IP or mDNS:

`ssh pi@raspberrypi.local`


(Works if mDNS/Avahi is enabled.)

**3) USB gadget mode (one cable, great for Pi Zero/CM)**

Best if one Pi is Pi Zero / [Zero 2 W](https://www.ampheo.com/product/raspberry-pi-zero-2-w-25441000) (or some Compute Module setups).

* Connect via the USB data port (OTG).
* The gadget Pi can appear as a USB Ethernet device to the other Pi.

This is excellent for “headless” setup and direct networking with one cable, but it’s model/port-specific.

**4) Serial UART (simple for control/debug, not for fast data)**

Good for console access or [microcontroller](https://www.ampheo.com/c/microcontrollers)-like links.

* Connect: GND↔GND, TX↔RX, RX↔TX (3.3V TTL only!)
* Enable serial in raspi-config (disable login shell if you’re using it for your own data).
* Use minicom, screen, or Python to communicate.

**5) GPIO/I2C/SPI (for hardware-style links)**

Use these if you’re building a custom hardware interface:

* I2C: one Pi can be master; multi-master exists but is more complex.
* SPI: one master, one slave (Pi as SPI slave is possible but not as straightforward as MCU).
* GPIO: simple signals/handshakes.

For most people, Ethernet or Wi-Fi is the correct answer.