0

So I have started a project and I would like to communicate between two or more pi's via an ethernet cable and without the use of an internet connection. I have read in another post on here that it is possible but I didn't feel that it gave enough info. So my questions are:

  1. Can I just use any cat5/6 cable or is there a special type that I need?

  2. Do I literally just connect the two pi's via their ethernet ports?

  3. In Python how would I do the communication?

  4. If I want to connect more pi's what do I use/how do I do it?

2 Answers 2

1

1) Can i just use any cat5/6 cable or is there a special type that I need?

Any Ethernet cable will work.

2) Do i literally just connect the two pi's via their ethernet ports?

Yes

3) In python how would I do the communication?

You would most likely use TCP sockets which allows for reliable messaging.

My pigpio Python module does this for you.

4) If I want to connect more pi's what do I use/how do I do it?

You would introduce a piece of hardware called a switch or a router and plug the Ethernet cable from each Pi into that device. That would automatically allow each Pi to communicate with the others.

3
  • So i would i just buy any router like the one i use in my home? And i have heard of both of these pieces of hard ware what is the difference between them.
    – Drok_
    Aug 26, 2017 at 21:06
  • 1
    @Drok_ All I could do is paraphrase the result of a web search. Best to look on the web for router versus switch.
    – joan
    Aug 26, 2017 at 21:40
  • 2
    A switch just transport Ethernet (LAN) traffic between the ethernet ports. A router is a device that route TCP/IP traffic between one network and others, normally used in between internet and local network (LAN). That was a rough description.
    – MatsK
    Aug 26, 2017 at 21:42
0

4) If I want to connect more pi's what do I use/how do I do it?

You need to configure the network, this is done by editing /etc/network/interfaces.

The address needs to be unique for each Raspberry Pi. And the gateway is not needed if there is no router with internet access connected.

So it looks something like this.

auto eth0
iface eth0 inet static
    address 192.168.12.7
    netmask 255.255.255.0
    gateway 192.168.12.254
5
  • Does the address matter or can i put any numbers there so long as its in the same format?
    – Drok_
    Aug 28, 2017 at 19:40
  • @Drok_ 192.168.xxx.xxx is to be used for private networks. xxx = 0 to 254. so you can use 192.168.12.1 to 192.168.12.254
    – MatsK
    Aug 28, 2017 at 19:46
  • Ok but one last thing that im confused on is that the examples you provided are both 192.168.12.xxx can that 12 be changed just to make it easier to read and if i were to change it does each pi have to have the same change?
    – Drok_
    Aug 28, 2017 at 19:52
  • I used 12 as a example since many home routers uses 0,1,2 in the third octet example, (xxx.xxx.12.xxx). You can use any no between 0-254.
    – MatsK
    Aug 28, 2017 at 20:04
  • Play a bit with this subnet-calculator.com
    – MatsK
    Aug 28, 2017 at 20:05

Your Answer

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

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