I would like to hook up my new Raspberry Pi A+ to an older B model without having to connect the A+ to WiFi. Can I connect them somehow via USB? Can I do it with a hub in between?
Connect them via UART! You will have them talking in no time.
Here is a link to get you started:http://www.raspberry-projects.com/pi/programming-in-c/uart-serial-port/using-the-uart
just connect tx to the other rx and rx to the other tx.
Yes! The Pi A, A+ and Zero are special, they each support USB OTG and can connect directly to other computers via USB.
These models alone are special and this feature does not exist on any Pi that has more than one USB data connector like the B, B+ 2B, 3B and likely not any bigger Pi in the future.
The basic steps are in this gist https://gist.github.com/gbaman/50b6cca61dd1c3f88f41
Note that the command including
BRANCH=next should not be used, it no longer works and isn't even available anymore, you just update your Pi the usual way and you'll get the updates needed.
I wanted to expand upon Chisight's helpful answer.
I lack a keyboard/monitor that can connect to a Pi, so I followed gbaman's "quick route" instructions linked from the first Gist.
I connected a Pi Zero to a Pi 3 B+ in this way. I could use
ssh to access the link-local name
raspberrypi.local with no problem, I think this is thanks to avahi-daemon. I also verified this using the command
getent hosts -s mdns4_minimal raspberrypi.local which I had learned about from this serverfault question. However, when the Pi Zero was connected to my Arch Linux machine I did not have a working
raspberrypi.local and so had to discover the IP of the connected device using
arp-scan as described here.
Being able to
ssh into the Zero was great, but not the end of the road. At this point the Zero did not have network access, and in fact its presence as a USB network device caused the Pi 3 to lose outgoing wireless access. (This was due to a
usb0 link-local entry which appeared in the Pi 3 routing table with higher priority than the wireless gateway) To give access to the Pi Zero, I configured a static IP for both ends of the USB device, and set up NAT on the Pi 3 to forward connections from the Zero. This was according to instructions from BurtyB on Freenode's #raspberrypi:
## Pi Zero add to /etc/dhcpcd.conf profile fb_usb0 static ip_address=172.19.180.1/24 static routers=172.19.180.254 static domain_name_servers=126.96.36.199 188.8.131.52 interface usb0 fallback fb_usb0 ## Pi 3 add to /etc/dhcpcd.conf profile fb_usb0 static ip_address=172.19.180.254/24 interface usb0 fallback fb_usb0 ## Pi 3 setup NAT sudo sh -c "echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf" sudo sysctl -p /etc/sysctl.conf sudo iptables -t nat -A POSTROUTING -s 172.19.180.0/24 ! -o usb0 -j MASQUERADE sudo iptables -A FORWARD -i usb0 ! -o usb0 -j ACCEPT sudo iptables -A FORWARD -o usb0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT sudo sh -c "iptables-save > /etc/iptables/rules.v4" # ^ first you need to # apt-get install iptables-persistent
These instructions could be easily adapted to give the Pi Zero network access via a laptop or other computer. Once I followed them, I was able to run
apt-get on the Zero and finish configuring it to my liking. Before BurtyB told me to use NAT, I had gotten sidetracked trying to set up a bridge with
brctl, which doesn't work between ethernet and wireless devices - so don't do that...
(Strangely, after I did these things I no longer had an issue with the routing table on the Pi 3. It had been suggested earlier that I configure metric values in
/etc/dhcpcd.conf to fix the routing priority table issue but the problem persisted, which was a mystery. This is from the Pi 3
$ ip route default dev usb0 scope link default via 192.168.1.1 dev wlan0 src 192.168.1.123 metric 200 169.254.0.0/16 dev usb0 proto kernel scope link src 169.254.38.33 metric 300 192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.123 metric 200
dhcpcd.conf still has the metric values:
interface wlan0 metric 200 # from BurtyB at #raspberrypi profile fb_usb0 static ip_address=172.19.180.254/24 interface usb0 fallback fb_usb0 metric 300
There are two options:
1.) A special USB Cable with USB-A Plugs on each end. They have a chip inside that tels both sides that this would be an USB Stick or something. So you will need a special software and that software for ARM to use it. So this is the hard way.
2.) Just use a Ethernet Cable and two USB-Ethernet Adapters. This will be supported by the Kernel and you now have a LAN connection between the two. Only issue is that at least one of the USB-Ethernet Adapters has to support Auto-MDI. If they both do not support it then you need a Cross-Over Cable. A cross over Cable is a special LAN cable that has a special pin layout so that two host can be connected with each other. In the normal case you connect a host to a switch. The Auto-MDI feature automatically detects if a normal cable or a cross over cable is needed and can do the cross over part automatically if needed.
As others have pointed out you can't do this via USB (at least without writing your own drivers).
There are 3 simple options (without any additional hardware); serial, SPI or I²C.
You first have to define what you are trying to achieve.
Serial is the time honoured solution; indeed once all UNIX machines did this, before IP was invented. There is a lot of support built into any Linux system to support this.
The other protocols are more suitable to using one device as a slave.
The only thing that comes close is to access one Pi over the Serial Console using a FTDI USB
These are the same used to programme Arduino 3.3v boards. basically it gives you a Console over USB on Pi, and a Serial on the other.
You asked for USB, but you may just connect the two directly RX to TX and TX to RX. The problem with this is that 2 is the max. There are ways to get more but it get more complicated than needed.