Build a Pi Zero from a USB port

Victor Benarbia
3 min readDec 17, 2017

In 2017, many technological advancement should make the world a better place. I’m not sure if that count but the Pi Zero is pretty amazing development platform. In this article, I would like to cover the “headless installation” because I did not find any good resource to explain how to configure a Pi Zero without connecting a monitor, a mouse, or a keyboard. The lower priced Pi Zero comes with micro USB interface which makes connecting regular USB difficult. You will need to a buy a USB HUB as an adapter which is probably 3x more expensive than the Pi Zero / 5 USD. If you do not want to do so this article is for you.

Pi Zero connected over SSH via USB port

In this article I’m going to explain how to take control of the Pi Zero over SSH with a simple USB cable. I have completed this procedure on Mac OSX but the link provided also detailed the process for Windows.

Required

  1. Pi Zero Wifi
  2. Micro SD card with 4Go or more…
  3. Wifi network information

Step 1 : Install an operating system
To set any Raspberry Pi in headless mode, you’ll only need to install Raspbian OS (latest is Stretch) on the SD card. The operating system can be download from this location:

To install the OS image on the SD card, there is use-full software named PiWriter. Here is youtube video.

Step 2. Make sure you know your Wi-Fi SSID and Password in order to perform headless setup. Once you’ve burned/etched the Raspbian image onto the microSD card, connect the card to your working PC and you’ll see the card being mounted as “boot”. Open the SD card, you need to make 2 new files.

Step 2.1: Create an empty file. You can use Notepad on Windows or TextEdit to do so by creating a new file. Just name the file ssh. Save that empty file and dump it into boot partition (microSD).

Step 2.2: Create another file name wpa_supplicant.conf . This time you need to write a few lines of text for this file. For this file, you need to use the FULL VERSION of wpa_supplicant.conf. Meaning you must have the 3 lines of data namely country, ctrl_interface and update_config

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="your_real_wifi_ssid"
scan_ssid=1
psk="your_real_password"
key_mgmt=WPA-PSK
}

If you’re provided is AT&T, open your web browser. http://192.168.1.254

Step 3. Allow the Pi to connect to your computer over USB. This article described the detailed process, but the quick steps are described below.

https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget?view=all#ethernet-gadget

Step 3.1 Edit the config.txt file located on the SD Card.
Add a new line at the bottom: dtoverlay=dwc2

Step 3.2 Edit cmdline.txt After rootwait (the last word on the first line) add a space and then modules-load=dwc2,g_ether

Step 4. Connect over SSH to your Pi Zero.
1. Unmount the SD card.
2. Plug USB to Micro USB between your laptop and mac
3. Wait for the Pi to boot.
4. Open a terminal on OSX
5. Enter ssh pi@raspberrypi.local
6. Password is “raspberry”
7. You are connected.

Note: To verify if the raspberry is properly connected via USD. Run the command “ifconfig -a” before and after connecting the USB cable, you should notice a new interface connected to your machine. (OSX Mojave)

If this does not work at first, you should read the article above or look at the source.

Happy coding..
Victor

sources:
https://www.raspberrypi.org/forums/viewtopic.php?t=191252

https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget?view=all#ethernet-gadget
https://www.raspberrypi.org/documentation/remote-access/ssh/unix.md

--

--

Victor Benarbia

Living the American dream in Austin TX, where I'm design automation engineer at ARM.