Connecting a Raspberry Pi Zero over USB

Some notes on how to use a Pi Zero without a lot of adapters and cables.

The Pi Zero is a cool bit of kit which has amazing capabilities but tends to need a spaghetti of wires to get it connected and up and running.

I read on the internet that the device can be used in a USB on the Go mode and in order to have a device that I can use pretty much anywhere I thought I’d give it a go.

I followed the instructions on the page http://blog.gbaman.info/?p=699 which are pretty self explanatory, although there were a couple of areas that weren’t entirely clear to me that I think I will clarify…

To make life easy, I used a Raspberry Pi 2 which I have to prepare the card ready for the Pi Zero. I downloaded the latest Raspian Jessie full implementation from the Raspberry Pi Foundation download page, expanded it from the zip file under Windows 10 and then wrote it to a Micro SD card using Win32Imager.

Once the writing was complete, I loaded the card into my Pi 2 with the easy to access ports and network to allow me easy access to the installed version to prepare it.  All the steps that you need to do can be done on this device, other than the update of the Pi firmware. (On my Pi Zero it was at the latest firmware level already so although that is in the instructions, if you got your Pi Zero in 2016 I suspect that you will be up to date enough for it to work)

The steps I used to get the Pi prepared were as follows

  • boot with keyboard, mouse and screen
  • set the Pi to boot to the command prompt as shown here and reboot
  • resize the root partition (sudo raspi-config, select expand and reboot)
  • add the line dtoverlay=dwc2 to /boot/config.txt (used sudo vi)
  • add the lines dwc2 and g_ether to /etc/modules (used sudo vi)
  • shutdown
  • the card is now mostly prepared and can be put into the Pi zero
  • I connected a power cable to the power socket and a network cable to a USB ethernet adaptor
  • I checked my router to find the IP address of the Pi Zero
  • Use ssh to log on to the Pi and then run the firmware update  sudo BRANCH=next rpi-update
  • Finally I added the config to the /etc/dhcpcd.conf file (sudo vi)
    interface usb0
    static ip_address=169.254.64.64
  • shutdown

This was all the prep and all that remained was to test the Pi

I plugged a standard USB cable into my PC and the mini end into the Pi, not into the Power port, but into the USB port. The PC is quite capable of providing the power for the Pi zero, so it becomes a single wire connection

It took a while for the drivers to be downloaded and installed for the USB ethernet

When it is recognised it appears as an adapter in the Control Panel ¬ Network and Internet ¬ Network Connections

You should be able to ping 169.254.64.64 from your PC and then ssh to 169.254.64.64 to access the Pi.

Remember this doesn’t give you access to the Internet from the Pi, but it does let you use it as a webserver or SQL database or programming test environment if you chose from any other computer, once config has been done.

 

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s