Tether RPi to iPad Pro via Ethernet over USB-C

Tether Raspberry Pi to iPad Pro via Ethernet over USB-C

The new USB-C connector on the 2018 iPad Pro’s opens a new way to communicate with RPi’s: Ethernet over USB, including powering a Pi Zero. The procedure to success was pretty straightforward and documented here for my own reference (so I won’t forget to enable ssh before booting up the new flash card) using a Raspberry Pi Zero W.

IMG_1160.jpeg

Download Raspian Stretch lite

Download the latest minimal image, which is Debian Stretch at the time of writing this post from https://www.raspberrypi.org/downloads/raspbian/:

Write image to flash card

I’m using balenaEtcher on OS/X to write the image to the memory card, then mount it on OS/X to get access to the cards /boot folder.

Enable Ethernet over USB

With the memory mounted, append the line dtoverlay=dwc2 to config.txt and add modules-load=dwc2,g_ether to the kernel argument list in cmdline.txt:

$ cd /Volumes/boot
$ echo 'dtoverlay=dwc2' > config.txt
$ sed -i '' 's/quiet/quiet modules-load=dwc2,g_ether/' cmdline.txt


Enable ssh

$ cd /Volumes/boot
$ touch ssh


That’s it! Unmount/eject the memory card and place it into the Pi Zero.

Wire it up

Connect the Pi Zero via the micro USB port next to the mini HDMI port and the other end to the iPad Pro, either directly via a micro-USB to USB-C cable or using one of the USB-C dongles and its USB port.

The Pi Zero will power on and boot up, indicating by the flashing green LED. It will go thru an automatic reboot after expanding the filesystem.

Go to the Settings on the iPad and wait for the Ethernet to appear, click on it and then on the ‘RNDIS/Ethernet Gadget’ adapter’ on the right and you’ll see shortly self assigned IPv4 address showing up (there is also a link local IPv6 address, but it isn’t shown):

BTW I set the iPad to Airplane Mode to make sure, there is no cheating going on here 😉

Connect via ssh

Use your favorite ssh client on the iPad and connect to the Pi Zero using its hostname raspberrypi.local, username pi and password raspberry:

ssh login

While logged in, check ifconfig usb0 and wo am i to verify how the ssh connection is made: via IPv6 using link local !

logged in

Unfortunately I didn’t manage to use the iPad’s Personal Hotspot to share its 4G/LTE connection with the RPi, but one can use the RPi’s wlan0 interface to connect itself to a Wifi network, e.g. via ‘sudo raspi-config’.

Summary

These simple steps I described above enable Ethernet over USB on the Raspberry Pi and allow it to communicate over USB with the iPad Pro, thanks to its new USB-C connector.
Some of the use cases I have in mind include some programming “on the go”, when offline. I successfully ran some Go programs. Other use cases I have in mind is to use this as a protable serial terminal server, all self powered from the iPad. Maybe even a VPN/Wifi router or .. or … or ..

I’m sure you’ll come up with much cooler use cases. Let me know in the comments section.

Update Dec 3rd, 2018

@gp_config shared his AirPiConsole use case, which is very interesting: https://www.ifconfig.it/hugo/tags/airpiconsole/ . Definitely on my todo list, hopefully before I’m in need of a serial console in a remote location …

14 thoughts on “Tether RPi to iPad Pro via Ethernet over USB-C

Add yours

  1. Thank you for the write-up, I assumed this was possible but it’s nice to see somebody actually try it and get it working. Do you know if this would work with a non-zero Pi?

    Like

    1. Yes. I just tried it out on a Pi 3 Model B+ connected directly to the iPad Pro 11”. Though for long sessions its better to also connect the iPad to an external power source (e.g. using one of the USB-C to USB/HDMI dongles).

      Like

      1. thanks for testing! so it was able to present itself as a ethernet device over the micro port? do you think the ipad has enough power to also power a peripheral connected to a non-zero pi at the same time?

        Like

      2. Yes, it presented itself as ethernet device (using the instructions from my blog). The RPi3 took about 2W from the iPad Pro, so there is probably room for an auxiliary device connected to the RPi3. The new iPad Pro offers power over its USB-C port, but I couldn’t find any spec how much. But of course this will drain your iPad battery. CORRECTION: OTG doesn’t work with RPi3, just power provided by the iPad works.

        Like

  2. thanks for testing, im surprised the B+ works, i had heard online it doesnt support OTG, i imagine it works because of usb-c. shame the zero doesnt have two usable data usb ports, would be nice to be able to plug in a disk and have it act as a go-between since ios doesnt like external drives as of now

    Like

    1. Argh. Fooled myself. You are correct, B+ doesn’t work with OTG over its micro-USB power port. I just happened to have my OTG flash also set to connect to WiFi and didn’t turn on airport mode on my iPad. Sorry about the confusion. Just PiZero for now …

      Like

      1. ah, too bad. i believe i read the a+ does have otg support, would be nice to have it on something a little more powerful than the zero, i dont believe its powerful enough for vnc/rdp and graphical applications

        Like

  3. Thank you for the post!

    I have followed your instructions, but the Pi never shows up on my iPad via the ethernet settings menu.

    I know that the Pi is booting as when I connect an HDMI cable I can see that it gets to the login screen when powered through the USB input from the iPad’s USB.

    I have followed your instructions correctly and cross referenced with other tutorials.

    Any ideas?

    Like

    1. Assuming you are using a PiZero (normal RPi won‘t work) and you are connecting to the correct USB port on the PiZero (the one closer to hdmi), then you might need to try another USB cable. If you got a charging only cable, it won‘t work.

      Like

      1. You can also use Apple’s USB-C to VGA/HDMI/USB dongle, combined with a USB cable. This is where I did run into the issue you described (wrongly using a charging only micro-USB cable). But most of my USB cables work just fine using the Apple adapter

        Like

      2. The new cable worked. As soon as I plugged it in I could see it in the menu and SSH using raspberry.local.

        Thank you again for this awesome tutorial!

        I used to achieve something similar with my old iPad Pro and 1st generation Pi Zero. I set a script that would run via a cron at boot up and check to see if the Pi could see any of my home wifi networks. If it couldn’t it would switch to broadcast mode and I could then connect my iPad to it as the server.

        With the Pi Zero W I had planned to do the same but also have the Pi connect via a USB wifi dongle to my phone so that it would share its internet also.

        With your demo there’s no need for me to do that!

        Liked by 1 person

  4. Does the usb0 device need a static ip address? I am using systemd-networkd on Arch Linux on a Pi 3. I have /etc/systemd/network/usb0.network set to use DHCP.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Up ↑

%d bloggers like this: