Table of Contents

Raspberry Pi Zero W

The Raspberry Pi was a remarkable computer when it was first introduced, and the people behind it have continued to innovate, with one of the most recent, smallest and cheapest being the Raspberry Pi Zero W.

It's not quite as cheap as the Raspberry Pi Zero, but since that device lacks any native networking capabilities (either cabled or wireless), its practical applications are severely limited.

Therefore this article discusses the Zero W, which has on-board 802.11 Wi-fi and Bluetooth. It has no wired ethernet connectivity, but it does have USB OTG, and you can plug in a USB-to-ethernet adapter if you really feel like it, to get a cabled eth0 interface. You can also plug in a USB Wi-fi adapter if that's your preference for obscure networking connectivity. Both of these options just work "out of the box" with standard Raspbian.

Getting started

Getting going with the Zero W can be a bit of a chicken-and-egg problem - it would be nice to plug in an SD card, power up the device, log in by SSH, and configure the wireless network credentials. Without the credentials, though, it can't get an IP address, so you can't log in by SSH

[Note: this is not an entirely unreasonable wish for a wireless-only device - after all, the Sonoff PoW and related devices have a client / server wireless mode, where they first try to connect to the configured wireless network as a client, but if that doesn't work, they revert to broadcasting as an open access point (server) of their own, which you can connect to, configure the wireless credentials, and thereby enable them to connect to your network on the next try.]

Fortunately, it is really easy to configure the network credentials of a Pi Zero W on the SD card before you plug it in to the Pi, so that the machine gets onto the network and acquires an address (and, if you have a sensible DHCP-to-DNS dynamic update system, you can then connect to it as "raspberrypi" on your local network domain).

  1. Start from the current Raspbian Stretch Lite image
  2. Download this to your computer, unzip it, and write the resulting .img onto a micro SD card (minimum capacity 2Gbytes, and just so you know, you really can have a usable system with only a 2Gbyte card)
    • Note that you do NOT want to mount any existing file system on the SD card and copy the image into that; WITHOUT mounting the SD card in any way, simply copy the downloaded image directly to the SD card itself (on Linux this will be /dev/sdg or similar - note that again, you should NOT write to /dev/sdg1, but simply to the raw device /dev/sdg)
  3. After writing the image, remove and re-insert the SD card to your computer, so that the new partitions get recognised
  4. Mount the partition named "boot" and view the file system it contains
  5. Create an empty file named "ssh" in this file system
    • This will cause the Pi to start an SSH server when it boots up - otherwise it will have an IP address but you have no way to connect to it…
  6. Create another file named wpa_supplicant.conf with the following content:
    wpa_supplicant.conf
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    
    network={
     scan_ssid=1
     key_mgmt=WPA-PSK
     ssid="YOUR_WIFI_ESSID"
     psk="YOUR_WIFI_PASSWORD"
    }
    • Edit the two items ssid and psk to match your own network credentials
  7. Unmount the file system, remove the card from your computer, insert it into the Pi and apply power

If you want a more (how much more? I don't know…) secure version of the wpa_supplicant.conf file, so that it does not contain a plaintext password, you can use the wpa_passphrase command:

$ wpa_passphrase YOUR_WIFI_ESSID
# reading passphrase from stdin
YOUR_WIFI_PASSWORD
network={
        ssid="YOUR_WIFI_ESSID"
        #psk="YOUR_WIFI_PASSWORD"
        psk=f082e6ee6d2ff53c36af97a57c8cffb39c02ce801bfaecd109cbdde9d8a4d1f4
}

You can remove the commented-out line containing the plaintext password, and use the rest of the above stanza in your wpa_supplicant.conf file.

Note that you can have multiple network={ … } stanzas in the file, so that the Pi can connect to any of several networks, depending on what it finds in its current neighbourhood.

Once you've set up the wpa_supplicant.conf file one way or the other, the Pi should now boot itself into Raspbian Stretch, connect to your wireless access point and request an IP address by DHCP, then start an SSH server listening on that address.

You can then SSH to it with the username pi and the password raspberry (which you should change as soon as you've logged in, using the passwd command). If you need to do stuff as root, sudo bash does not require a password (I said these things were small and cheap, I never said they were secure - that is left as an exercise for the owner afterwards).

Root over NFS?

In many cases, I far prefer to run my Raspberries with the root FS mounted over NFS, and this is easy to do when the machine has an ethernet socket and a wired connection.

Doing the same thing over wireless, however, is not so simple, so here's a guide to what you need to do.

Root over iSCSI?

These look interesting:

Update - I've succeeded in doing this (it's no more complicated than root over NFS, just a bit different, naturally); I just need to get around to writing it up here.


Go up
Return to main index.