chaft
Posts: 5
Joined: Sat Mar 04, 2017 5:25 pm

Help Connecting Two Pis over Ethernet

Sat Mar 04, 2017 5:45 pm

Hello,

I am working on an ROV project where we are required to use a wired tether to communicate with the Raspberry Pi which is mounted to the ROV. We have to use a Pi since we need to receive video from a USB Webcam, and we are hoping to stream that video back to the surface while receiving simple commands (serial communication is the current method) over Ethernet. The problem is, we were hoping to not need to use a laptop on the surface, and would prefer to use a second Raspberry Pi.

We are using a form of communication used by OpenROV which successfully communicates video and control commands with the same system - it's a Tenda Homeplug adapter which allows for use of Ethernet/LAN over two wires and distances of over 100 meters. I know it's possible to use SSH to communicate between two Pis, but over WiFi, and found nothing online about how to do it locally with a wired connection. We still need to be able to send video, however. I'm fairly certain anything that would work to communicate through a single ethernet cable between the Pis would work using the Homeplug system as well. I am also aware it's fairly easy to communicate between a (Windows 10) Laptop and a single Pi over Ethernet, which is the fall-back plan.
Both Pis are model 3B if that makes any difference.

TL;DR:
  • Is it possible to communicate over Ethernet between two Pis like through WiFi to stream video and serial communications (or other text-based information)?
  • How can I go about accomplishing this, with little prior experience with Linux?
Here's the ROV as-is, with control signals sent through Cat5 from the surface and a 50-foot USB extension for the camera. Our goal is to get to over 100 feet deep so that won't work in the future.
https://www.youtube.com/watch?v=UpsQK96oNsM

W. H. Heydt
Posts: 12648
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Help Connecting Two Pis over Ethernet

Sat Mar 04, 2017 9:21 pm

Yes...though it'll be easier if you have a router.

The specified limit for USB cables is 5 meters (about 16 feet). If you have a 50 foot USB extension cable, it has to have some active elements in it (or it converts USB to some other protocol and converts it back at the other end).

chaft
Posts: 5
Joined: Sat Mar 04, 2017 5:25 pm

Re: Help Connecting Two Pis over Ethernet

Sun Mar 05, 2017 12:27 am

W. H. Heydt wrote: If you have a 50 foot USB extension cable, it has to have some active elements in it (or it converts USB to some other protocol and converts it back at the other end).
This is why we were hoping to replace the USB cable with Ethernet as well.
You mentioned it would be helpful to have a router - would that need to be on the ROV or on the surface? And what would we need it to accomplish?

Thanks!

W. H. Heydt
Posts: 12648
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Help Connecting Two Pis over Ethernet

Sun Mar 05, 2017 12:52 am

chaft wrote:
W. H. Heydt wrote: If you have a 50 foot USB extension cable, it has to have some active elements in it (or it converts USB to some other protocol and converts it back at the other end).
This is why we were hoping to replace the USB cable with Ethernet as well.
You mentioned it would be helpful to have a router - would that need to be on the ROV or on the surface? And what would we need it to accomplish?

Thanks!
A router would serve as a DHCP server and supply IP addresses to both the ROV and the surface systems with IP addresses in the same IP bock. A Pi2B or Pi3B could *probably* operate as both a router and the surface base station, though. What I would be most concerned about if I had this project would be getting a WiFi signal to go through very much water. So far as I know, you're much better off using low frequencies for better penetration into water than either 2.4GHz or 5GHz.

I know that Monoprice sells USB over Ethernet/CAT-5 range extenders, but I don't think they're designed to work under water. What might be better would be some form of optical link with converters to and from USB at the ends, with the main cable sealed to a fare thee well where it enters the case.

You don't say how deep your ROV is going to be, and that rather strongly affects how good your cables, housings, sealing glands and so on have to be. Bear in mind that each 30 feet of water is 1 added atmosphere pressure (~15 psi), so all those seals and what not need to be rated for something greater than the actual expected operational depth...and that means you really don't want to use common cabling. It's not designed to use under those conditions.

chaft
Posts: 5
Joined: Sat Mar 04, 2017 5:25 pm

Re: Help Connecting Two Pis over Ethernet

Sun Mar 05, 2017 1:23 am

As mentioned, we are not intending to use WiFi, it's useless through water. I also did mention at the end our hope is depths beyond 100 feet - the ROV has been successfully tested to a depth of 30 feet. I am hoping to just get a system working on land that is possible to get working underwater, and then we can worry about waterproofing and pressure-proofing at a later date. It's been proven that ethernet over 2-wire Homeplug works fine even at depths of over 300 feet (100 meters).
I know that Monoprice sells USB over Ethernet/CAT-5 range extenders, but I don't think they're designed to work under water.
I may not have been clear before - we're making huge changes to accommodate problems like this. Instead of running USB and Cat5 underwater, we are going to be running just power wires and the two Homeplug wires underwater. The Pi connected to the camera is gonna be on the ROV underwater, so the camera USB will plug into USB on the Pi and then ideally we send the video out of the Ethernet port of the Pi and up to the surface through the Homeplug system (which is identical to Ethernet over Cat5/Cat6).
A Pi2B or Pi3B could *probably* operate as both a router and the surface base station, though.
That's great to hear. How could I go about setting this up?

W. H. Heydt
Posts: 12648
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Help Connecting Two Pis over Ethernet

Sun Mar 05, 2017 4:31 am

I've never set up a Pi as a router. I just buy routers (they're cheap enough). Google is your friend....

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Help Connecting Two Pis over Ethernet

Sun Mar 05, 2017 9:45 am

Why use a homeplug? CAT5 ethernet is good for 100m (~328ft) run that with a PoE HAT on the remote RPi.

Whatever you do get a small 100Mbps ethernet switch at the surface to join everything together.
http://uk.tp-link.com/products/details/ ... 1005D.html is what I use with my Raspberries.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

drgeoff
Posts: 10765
Joined: Wed Jan 25, 2012 6:39 pm

Re: Help Connecting Two Pis over Ethernet

Sun Mar 05, 2017 10:07 am

You don't need a router or switch. Give each of the two RPis a static IP address and join them with an ethernet cable. (Doesn't even need to be a crossover cable as the RPis have autosensing interfaces.)

Ernst
Posts: 1334
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Help Connecting Two Pis over Ethernet

Sun Mar 05, 2017 10:16 am

And two 100 MBit/s circuits can be connected using a single CAT5 cable using a simple splitter.
The road to insanity is paved with static ip addresses

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Help Connecting Two Pis over Ethernet

Sun Mar 05, 2017 10:38 am

drgeoff wrote:You don't need a router or switch. Give each of the two RPis a static IP address and join them with an ethernet cable. (Doesn't even need to be a crossover cable as the RPis have autosensing interfaces.)
With a switch you can easily connect a laptop to gain access to the otherwise closed system.

The way I do it during development is to run a fixed IP & dnsmasq on the primary RPi. That hands out an IP address to the remote RPi and when I plug in my laptop it hands out another IP address to that. Once the system is debugged then I agree with you the switch isn't needed just use a straight cable between the two Raspberries. The command and control system continues to run dnsmasq with a fixed IP and the remote system continues to be a stock standard DHCP client.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

chaft
Posts: 5
Joined: Sat Mar 04, 2017 5:25 pm

Re: Help Connecting Two Pis over Ethernet

Mon Mar 06, 2017 12:15 am

DougieLawson wrote:Why use a homeplug? CAT5 ethernet is good for 100m (~328ft) run that with a PoE HAT on the remote RPi.

Whatever you do get a small 100Mbps ethernet switch at the surface to join everything together.
The HomePlug can extend the range to 300 meters. Besides, it should behave the same, and it makes the tether easier to get neutrally buoyant (trapped air or other insulation materials in Cat5 cables makes this a challenge) plus the AV cables are literally just insulation over copper wires, so they can deal with insane amounts of water pressure with no modifications needed, and are very flexible. Not to mention far less expensive!

Using PoE is impractical as we are powering the motors with 12 volts at far too high an amperage, and we are going to simply use a 12V-5V DC-DC converter on the ROV to power all logic-level devices.
Thanks for the suggestions though! It's good to know we can use a network switch in any case.

chaft
Posts: 5
Joined: Sat Mar 04, 2017 5:25 pm

Re: Help Connecting Two Pis over Ethernet

Mon Mar 06, 2017 12:20 am

DougieLawson wrote:
drgeoff wrote:You don't need a router or switch. Give each of the two RPis a static IP address and join them with an ethernet cable. (Doesn't even need to be a crossover cable as the RPis have autosensing interfaces.)
With a switch you can easily connect a laptop to gain access to the otherwise closed system.

The way I do it during development is to run a fixed IP & dnsmasq on the primary RPi. That hands out an IP address to the remote RPi and when I plug in my laptop it hands out another IP address to that. Once the system is debugged then I agree with you the switch isn't needed just use a straight cable between the two Raspberries. The command and control system continues to run dnsmasq with a fixed IP and the remote system continues to be a stock standard DHCP client.
This all sounds very helpful. Thanks! It sounds like it's a good idea to have a switch on hand since it hardly adds any complication and makes it easier to troubleshoot/debug everything.

This might sound like a dumb question, but we can use Python to communicate, right? Is there some simple way to make one Pi send commands and the other 'listen' for them?

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Help Connecting Two Pis over Ethernet

Mon Mar 06, 2017 12:41 am

Once you have an IP connection then any sensible IPv4 TCP/IP, UDP/IP or ICMP/IP protocol can run over that. With a little extra effort that could be IPv6.

netcat, http, telnet, ssh, openvpn, vnc, sql (including jdbc, odbc and drda), mqtt, https, ftp, sftp, rexec, gopher, smtp
are the common protocols (although it's been a long time since I used a gopher server).

If you want to write your own python sockets programs and develop a roll-your-own protocol then fill your boots.

Personally, I'd install mosquitto on the command and control server and get the remote RPi to subscribe and publish MQTT topics as needed. MQTT is the Internet of Things protocol and was designed with stuff like SCADA in mind. For the C&C application I wrote the comms between commander (running a Tkinter GUI) and controlled system (which switches a bunch of relays) is a series of simple MQTT messages. The maximum size of an MQTT message will easily hold an image blob (the protocol is very much agnostic to the payload contained in MQTT messages).

I'm a massive fan of drda which is an exquisitely detailed protocol for shipping sql to host systems from remote systems (and lots of them) and shipping results sets back from a database server. As part of my day job we have a couple of Z13 mainframe servers that runs billions of SQL queries every day that way.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

htapaha
Posts: 1
Joined: Wed Apr 19, 2017 2:22 am

Re: Help Connecting Two Pis over Ethernet

Wed Apr 19, 2017 2:44 am

This is a topic that I am interested in as well, I do not know if I will be any help here. But I have been talking with some other people that have used a raspberry pi 3 as a server and it would be used as a communications hub for the usb camera and an arduino that would control motor drivers.

Return to “Beginners”