1

I’m planning a project where a RPI zero will be controlling a flying vehicle. It’s going to have 2 (maybe 3) cameras as an input. These will be connected over USB. I’m aware that processing the information from the cameras will require a lot of work, so the plan is to couple a second RPI zero to the first one, which will read the cameras and do some image preprocessing before feeding the information into the flight controlling RPI. This will lower the load on the first PI, and will make it much easier and safer to handle potential problems on the camera side of the system.

I know there are lots of ways to chain computers together, but a local network seems like the best plan for my case. Everything however has to be compact, so the two RPIs will simply be stacked on top of each other.

I’ve done some experiments with 2 Zero-W’s, where one is hosting a wifi network and the other one connects to it. The whole system works great this way. This of course isn’t ideal, so I’d like to replace this with a wired connection without having to change up the code completely.

I’m pretty sure this is possible, but I’m not really an expert in this matter. How should I set up this system so a local network exists where each RPI has an IP to connect to the other one, while connecting them over their GPIOs?

EDIT I could just use a pi with more power. There are however a few reasons why I don’t. 1: the zeros are cheaper, I have a bunch of them laying around, and their dimensions fit the project better. 2: The vehicle I’m talking about is and will be a platform for experiments. For its core business (flight) it will need 2 zeros (well 1 really, the cameras aren’t flight-critical, but the project is just pretty useless without them) but all sorts of experimental systems will be added in the future. Stepping up from 2 zeros to 10 zeros with a local network doesn’t seem to difficult. If I however use 1 board for everything, this will get complicated quickly. 3: It seems like a good idea to have flight-critical systems on a seperate board.

I know I could use other protocols like UART, I2C etc. but a local network just makes everything much easier and as far as I know much more data can be transferred, keeping the project open for expansion/experimentation. As I said, wifi works perfect. I don’t want to lower the baud rates and make everything difficult. It’s just that wifi seems silly and inefficient as a communication line between boards sepperated about 8mm apart where a physical connection is perfectly possible.

  • Why not use 1 Pi3B+ or Pi4? – CoderMike Oct 8 at 9:09
  • There are 3 reasons, which I should have mentioned. 1: the zeros are cheaper, I have a bunch of them laying around, and their dimensions fit the project better. 2: The vehicle I’m talking about is and will be a platform for experiments. For its core business (flight) it will need 1-2 zeros, but I all sorts of experimental systems will be added in the future. Stepping up from 2 zeros to 10 zeros with my approach doesn’t seem too difficult. If I however use 1 board for everything, this will get complicated quickly. 3: It seems like a good idea to have flight-critical systems on a seperate board. – eds1999 Oct 8 at 9:42
  • When RpiZ and RpiZW came out a couple of years ago, I bought three and started playing with them. At the same time I had 4 Rpi3B+. Very soon I found that RpiZ/W are very slow, compared with 3B+. I struggled, and spent perhaps 100 hours trying things, before giving up, for other reasons I skipped here. I understand your project proposal, and your reasons for using Z/W for development. But I think I would rather use 2 Rpi4B to start with, planning everything scalable to many more say 10 RpiZ, without any development work on Z. Everything developed in 4B, then port to Z, ... – tlfong01 Oct 8 at 11:42
  • There's an A version of the Pi3, it's perhaps twice the size of the zero. – user2497 Oct 19 at 17:04
2

Put one Pi Zero in USB Gadget mode for Ethernet. This will create the equivalent of a WiFi network between them only needing one USB cable and some software configuration. You could solder the test pads for the USB ports together once you're in a stable working configuration to save on weight.

Following directions from here and here:

  1. echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt to enable the overlay for gadget mode.
  2. Add modules-load=dwc2,g_ether to the end of /boot/cmdline.txt to specify the Ethernet gadget.
  3. Configure static Ethernet interfaces on both Pi Zeros by editing /etc/network/interfaces/ and adding
allow-hotplug usb0
iface usb0 inet static
        address 192.168.7.X
        netmask 255.255.255.0
        network 192.168.7.0
        broadcast 192.168.7.255

where X is a different address for each Pi. You may need to change the usb0 to whatever new interface is registered for gadget mode, check this using ifconfig -a.

0

I understand you question that you do not use (most) GPIO pins but the USB port ist occupied with other devices. Hence a USB ethernet adapter is not a desired option. You can get your local network quite easily over GPIO using ENC28J60 Module.

This Module is supported by Raspbian and requires no additional drivers. Just enable it by adding dtoverlay=enc28j60 in config.txt. Here is a tutorial in german.

It offers only up to 10 Mbit/s but once enabled you treat it as if it was an on-board ethernet adapter. So the same network configuration requirements apply. In your instance you would have to assign static IP addresses (or install a DHCP server on one of them) and perhaps enable samba sharing for file transfer (albeit SSH, SCP, RSYNC will work just as well).


Using multiple Raspberry Pi Zero W would be even easier as one can host a WiFi and all the other connect to it.


Alternatively you can use Bluetooth. You can configure it to get an ethernet stack on top of that as well.

  • Thank you for this. I didn’t know about the ENC28J60. It’s pretty great! It however doesn’t really help me out a lot here. I didn’t specificly state this in my quiestion, but my intention is to directly have communication over GPIO, not with a chunky board in between. As said before, wifi works great, I don’t want to drop all its advantages and I don’t want to add weight to the vehicle as it will reduce its flying capabilities. It’s just that wifi is pretty silly for in-device-communication. – eds1999 Oct 11 at 9:07
  • You always can use UART for that. But you will have to write your own software for the data transmission. Just three wires (RX, TX and GND) and a proper setup of Serial in rpi-config. But then this is not a network but a peer-to-peer connection. – kwasmich Oct 11 at 9:11

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.