3

I'm currently working on a project that uses a rpi to do controls and data acquisition on a hydroponics system. However, I want to use another pi as a webserver that would also host a database for the first pi to send sensor information to and allow access on a webpage.

My question is, can I connect these two pi's directly via their Ethernet ports? How can i do this? or whats the best way to connect the pi's? I know I can run the server and db on the first pi but I cant have this for my project. The server and db must be external so I want to use another pi for this.

thank you.

1 Answers1

4

The simplest way to hook up the two Pi's is to

  • have a cat5e/cat6 cross over cable of sufficient length
  • configure each Pi to have a unique static IP within the same network by editing the /etc/network/interfaces

e.g on PI 1

auto eth0
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.6

on PI 2

auto eth0
iface eth0 inet static
address 192.168.1.6
netmask 255.255.255.0
gateway 192.168.1.5

This will allow each Pi to see the other but not any other device on the subnet kinda making the setup secure (?) and inflexible (no way to access the db/web server now :( from any other machine)

Alternatively as you are using the Pi3, you can configure the web server PI as an AP (access point) and make the other connect to the first one saving some $ in the process, assuming the distance & bandwidth isnt an issue. You must of course setup the security features as well. This will allow you to access the web server from any wifi enabled device.

Third option is a hybrid of the first two options, the 2 pies talk to each other over ethernet, and external devices connect over wifi with the web server PI acting as AP. If configured as different networks, your application(s) will have be properly configured to accept / connect over specific interfaces or you can setup a bridge to make both the wifi and ethernet into one network.

Shreyas Murali
  • 2,416
  • 1
  • 15
  • 22
  • 2
    Good answer but: You don't need a crossover cable. For a while now ethernet contollers (including those on all Pis) have commonly been able to detect when tx/rx are crossed and will adjust accordingly. I.e., normal cat 5/6 cable is fine. – goldilocks Oct 01 '16 at 01:45
  • @goldilocks nice to know ! i havent really needed to use a 2 system network in a while now, and certainly not with the PI – Shreyas Murali Oct 01 '16 at 01:48
  • I just found this out last year playing with a pair of them: http://raspberrypi.stackexchange.com/a/37596/5538 – goldilocks Oct 01 '16 at 01:50