Raspberry Pi Zero W User Manual

This installation of Home Assistant requires the Raspberry Pi to run Raspbian Lite. The installation will be installed in a Virtual Environment with minimal overhead. Instructions assume this is a new installation of Raspbian Lite.

Raspberry Pi Zero (and Pi Zero W) and the Raspberry Pi 3. Both boards are identical in features except that the W has built in Wifi and Bluethooth. Getting started with the Pi Zero board can be a little more cumbersome than with the Pi 3 because many of the connectors need adapters to connect to standard size connectors. Otherwise, to get started. Mar 09, 2018  If you have a Pi Zero W, see: Setup Pi Zero W Headless Wifi. To connect my Pi Zero 1.3 over WiFi I ordered an adapter from AdaFruit. The white cable in the picture above is a Micro-USB adapter. You can buy it separately or as part of the Pi Zero budget pack. Miniature WiFi (802.11b/g/n) Module: For Raspberry Pi and more. This guide will cover the latest version of the Zero product line, the Raspberry Pi Zero - Wireless, which has an onboard WiFi module. While these directions should work for most any version and form factor of the Raspberry Pi, it will revolve around the Pi Zero W.

You must have Python 3.7 or later installed (including the package python3-dev) which is not the case for Raspbian Stretch.

Vilros offers Raspberry Pi Kits, Raspberry Pi accessories and Retro Pie Retro Gaming Kits and accessories for those hard core old school gamers! Top notch USA based customer service and support. Free shipping on most items! Raspberry Pi Zero W desk clock. Back to project overview. An LED desk clock driven by NTP on a Pi Zero W. If you're using a Pi Zero W (or a Pi 3) and want to use the serial console, before you remove the card mount the FAT filesystem and edit config.txt to add somewhere near the end. Change the password for the 'pi' user. If you want to use Zero4U on Raspberry Pi Zero W, only the Zero4U for V1.3 has the possibility, as the positions for PP1, PP6, PP22 and PP23 testing pads are the same for Raspberry Pi Zero V1.3 and Raspberry Pi W. You will also need to use the ferrite ring (included in the package) to protect the pogo pins from WiFi interference.

Although these installation steps specifically mention a Raspberry Pi, you can go ahead and proceed on any Linux install as well. This guide is also referred to as the 'Advanced Guide' for a virtual environment install.

Please remember to ensure you’re using an appropriate power supply with your Pi. Mobile chargers may not be suitable, since some are designed to only provide the full power with that manufacturer’s handsets. USB ports on your computer also will not supply enough power and must not be used.

Connect to the Raspberry Pi over SSH. Default password is raspberry.You will need to enable SSH access. The Raspberry Pi website has instructions here.

Changing the default password is encouraged.

Update the system.

Install the dependencies.

Add an account for Home Assistant called homeassistant.Since this account is only for running Home Assistant the extra arguments of -rm is added to create a system account and create a home directory. The arguments -G dialout,gpio,i2c adds the user to the dialout, gpio and the i2c group. The first is required for using Z-Wave and Zigbee controllers, while the second is required to communicate with Raspberry’s GPIO.

Next we will create a directory for the installation of Home Assistant and change the owner to the homeassistant account.

Next up is to create and change to a virtual environment for Home Assistant. This will be done as the homeassistant account.

Once you have activated the virtual environment (notice the prompt change) you will need to run the following command to install a required python package.

Once you have installed the required python package it is now time to install Home Assistant!

Start Home Assistant for the first time. This will complete the installation for you, automatically creating the .homeassistant configuration directory in the /home/homeassistant directory, and installing any basic dependencies.

You can now reach your installation on your Raspberry Pi over the web interface on http://ipaddress:8123.

When you run the hass command for the first time, it will download, install and cache the necessary libraries/dependencies. This procedure may take anywhere between 5 to 10 minutes. During that time, you may get “site cannot be reached” error when accessing the web interface. This will only happen for the first time, and subsequent restarts will be much faster.

If you want to setup hass as a daemon and autostart it on boot please refer to Autostart Home Assistant.

Updating

To update to the latest version of Home Assistant follow these simple steps:

Once the last command executes, restart the Home Assistant service to apply the latest updates. Please keep in mind that some updates may take longer to start up than others. If Home Assistant fails to start, make sure you check the Breaking Changes from the Release Notes.

Run a specific version

In the event that a Home Assistant version doesn’t play well with your hardware setup, you can downgrade to a previous release. For example:

Run the beta version

If you would like to test next release before anyone else, you can install the beta version released every two weeks, for example:

Run the development version

If you want to stay on the bleeding-edge Home Assistant development branch, you can upgrade to dev.

The 'dev' branch is likely to be unstable. Potential consequences include loss of data and instance corruption.

For example:

Activating the virtual environment

When instructions tell you to activate the virtual environment, the following commands will do this:

PagesFavoritedFavorite9

Introduction

The Raspberry Pi is a popular Single Board Computer (SBC) in that it is a full computer packed into a single board. Many may already familiar with the Raspberry Pi 3 and its predecessors, which comes in a form factor that has become as highly recognizable. The Raspberry Pi comes in an even smaller form factor. The introduction of the Raspberry Pi Zero allowed one to embed an entire computer in even smaller projects. This guide will cover the latest version of the Zero product line, the Raspberry Pi Zero - Wireless, which has an onboard WiFi module. While these directions should work for most any version and form factor of the Raspberry Pi, it will revolve around the Pi Zero W.

Raspberry Pi Zero W

DEV-14277
27
FavoritedFavorite54

Raspberry Pi Zero W (with Headers)

DEV-15470
1
FavoritedFavorite4

If you're looking for a starter pack, this kit includes everything you need to start using your Pi Zero W.

SparkFun Raspberry Pi Zero W Basic Kit

KIT-14298
3
FavoritedFavorite10

Required Materials

To follow along with this tutorial, you will need the following items:

  • Monitor
  • Keyboard
  • Mouse (optional but suggested)
  • USB hub (for more than one USB device)

Suggested Reading

Here are some tutorials you may find interesting before continuing:

Single Board Computer Benchmarks

How to set up different benchmarking programs on single board computers or computing modules and run them. The results for various generations are shown on the subsequent pages.

SD Cards and Writing Images

How to upload images to an SD card for Raspberry Pi, PCDuino, or your favorite SBC.

Raspberry gPIo

Raspberry Pi

How to use either Python or C++ to drive the I/O lines on a Raspberry Pi.

Raspberry Pi SPI and I2C Tutorial

Learn how to use serial I2C and SPI buses on your Raspberry Pi using the wiringPi I/O library for C/C++ and spidev/smbus for Python.

Hardware Overview

Let's go over some of the most noticeable differences between the Raspberry Pi Zero (and Pi Zero W) and the Raspberry Pi 3.

Both boards are identical in features except that the W has built in Wifi and Bluethooth. Getting started with the Pi Zero board can be a little more cumbersome than with the Pi 3 because many of the connectors need adapters to connect to standard size connectors. Otherwise, to get started, all you need is a uSD card with a Raspberry Pi image on it and power.

Mini HDMI

Unlike the previous models of the Raspberry Pi which use a standard HDMI connector, the Zero uses a mini HDMI connector to save space. To connect the Zero to a monitor or television, you will need a mini HDMI to HDMI adapter or cable.

USB On-the-Go

The Raspberry Pi 3 and other models have traditionally had 2-4 standard size female USB connectors, which allowed for all variety of devices to connect including mice, keyboards, and WiFi dongles. Again to save space, the Zero has opted for a USB On-the-Go (OTG) connection. The Pi Zero uses the same Broadcom IC that powered the original Raspberry Pi A and A+ models. This IC connects directly to the USB port allowing for OTG functionality, unlike the Pi B, B+, 2 and 3 models, which use an onboard USB hub to allow for multiple USB connections.

To connect a device with a standard male USB connection, you will need a USB OTG cable. Plug the microUSB end into the Pi Zero, and plug your USB device into the standard female USB end.

For use with other standard USB devices, it is recommended that you use a powered USB hub. Wireless keyboard and mouse combos work best as they have one USB dongle for both devices.

Buy Raspberry Pi Zero W

Power

Like other Pis, power is provided through a microUSB connector. Voltage supplied to the power USB should be in the range of 5-5.25V.

microSD Card Slot

Another familiar interface is the microSD card slot. Insert your microSD cards that contains your Raspberry Pi image file here.

WiFi and Bluetooth

As with the Raspberry PI 3, the Zero W offers both 802.11n wireless LAN and Bluetooth 4.0 connectivity. This frees up many of the connections that would have been made over USB, such as a WiFi dongle and a USB keyboard and mouse if substituting a Bluetooth keyboard/mouse.

Camera Connector

The Raspberry Pi Zero V1.3+ and all Zero Ws have an onboard camera connector. This can be used to attach the Raspberry Pi Camera module. However, the connector is a 22pin 0.5mm and different than the standard Pi. You will need a different cable to connect the camera to the Pi Zero W.

GPIO

As with all other models of the Raspberry Pi, there are a plethora of GPIO pins broken out, many of which other other functionality such as I2C. If you are using the GPIO header, you may want to consider soldering headers to it.

Additional Connections

Last, you may notice two sets of thruhole pads labeled TV and Run. The TV pads allow you to connect an RCA jack to the board instead of using the HDMI out. The Run pins connect to the chips reset pin and will either turn the board off or turn it back on once it has been shutdown. Connecting a button here is a good way to power cycle your board.

For a complete description of each pin on the GPIO header and all the connectors on the PI Zero, consult the graphical datasheet below.

Hardware Assembly

Depending on your use case, setup for the Pi Zero can be minimal, or it can be cumbersome due to smaller connectors on the Zero and the adapters needed to connect standard devices such as mice, keyboards, and monitors.

Monitor

  1. To attach the Pi Zero to a Monitor or TV that has an HDMI input, attach a miniHDMI to HDMI cable or adapter to the miniHDMI connector on the Pi Zero. Connect the other end to the HDMI port on your monitor or television.

  2. Connect the USB OTG cable to the Pi Zero via the microUSB connector. If you have a keyboard/mouse combe, attach your dongle to the standard female USB end. If you have a separate mouse and keyboard, you will need a USB hub to attach both tto the USB OTG cable.

  3. Make sure that you have a valid Raspberry Pi image on your microSD card (more on this later). Insert the microSD card into the microSd slot.

  4. Power your Pi Zero via the microUSB power input.

There are a few other connectors to point out but we won't be using. The Pi Zero has a 40 pin GPIO connector on the board that matches the pinout of the standard Pi 3. You can solder wires, headers or Pi Hats to this connector to access the GPIO pins or even power. The camera connector will allow you to connect the Raspberry Pi camera although it is worth noting that the connector is a 22pin 0.5mm and different than the standard Pi and will need a different cable to connect the camera to the Pi.

Installing the OS

When it comes to crating an image on an SD card for your Pi Zero W, there are two options.

Option 1: NOOBS

The Raspberry Pi foundation has created NOOBS (New Out Of the Box Software) which is easy to use and get you started. Most generic kits such as the Pi3 Starter Kit will come with a NOOBS uSD card. Unfortunately as of the release of the Pi Zero Basic Kit the NOOBS image will need to be updated to work on the Pi Zero boards. If you don't have a current NOOBS image or just want to start again from scratch installing NOOBS is easy, you don't need any special software to install it on a card. Just download the image, unzip, drag and drop the files to your card, and you are good to go. Once you have NOOBS on your card, insert it in your board, apply power, and you should see action on your screen. Follow the prompts and install Raspbian (you may also want to select a differernt region for your keyboard and language). You can also go into the Wifi screen and setup Wifi. If you do you will get a lot more options for images to install.

You will not see most of these options unless you are connected to the internet

Option 2: .img File

If you want something other than the basic Raspbian install or other options found on NOOBS, you will need to install your own image on the uSD card. This method is slightly more involved because you need a special *.img file that not only puts your files on the card, but also sets up things like making the card bootable. The Raspberry Pi foundation has a handful of images like Ubuntu, OSMC (Open Source Media Center), and even Windows 10 IOT Core. A google search will find many more including specialized images for certain tasks. If you've never worked with Raspberry PI before, we recommend Raspian. You can download the latest version using the link below.

Heads up! When installing Raspbian, you do not need to worry about which model Raspberry Pi you are using. However, other Raspberry Pi image files, such as OSMC or RetroPi, have images that are designed for different models, often distinguishing between the Pi 2 or 3 and older models. Because those Pis use a slightly different processor than the Zero, these images won't work. The good news is that the Zero line uses the same chip as the older Raspbery Pi A/A+/B/B+ models, so there are still a lot of images out there for it. Visit this link for a breakdown of each Pi model.

To install your own image on your card, we recommend software called Etcher. These guys have taken all the different steps needed and put them all in one piece of software to take care of everything. Download your image, then run the program, select your image, select your uSD card drive, and then hit flash. Once it is done, remove your card and you are good to go. Once the image is installed, insert the card into the board and apply power.

For Mac users, the ApplePi Baker Software is a great way to upload a new image to an SD card. It will ask for an admin password upon startup. Select the SD card on the left plane, then upload your image iundet the Pi Ingrediants: IMG Recipe section. Click Restore Backup, wait for the progress bar to finish, and you're done. The program even ejects the card you, so can yank it right out and insert it into your Pi.

For the rest of this tutorial, we'll assume you've installed Raspbian either by installing the image directly or with Noobs. The tutorial should also work fine for most Linux based systems with a Graphical User Interface, but things might be in slightly different locations

Using Raspbian

Now that you've gotten your board up and running let's go over some basics.

Raspbian and most Raspberry Pi OSes are going to be Linux based. Don't let that scare you too much. Gone are the days of having to remember lots of commands or that you need to type :wq to save and exit your text editor. Linux now a days has a Graphical User Interface (GUI) similar to Windows or MacOS, and, while you will probably want to learn a few basic commands and shorcuts, you can usually get away with not using them.

In the upper left hand corner of Raspbian you will see six icons. The first is a Raspberry. This is basically the same as your 'Start Menu' on Windows machines. Click on this, and you will see a menu of all the installed programs as well as the shutdown options. The second icon looks like a globe, and it is the Web Browser. Then we have the 'File Manager', 'Terminal', 'Mathematica', and finally 'Wolfram'.

Raspbian OS Desktop as of 07/2017.

Changing Your Password

An important thing to remember is that Linux has user names and passwords. The default Raspian user id is 'pi' and the password is 'raspberry'. The second thing to remember is that I know your user id and password and so do lots of other people with less honorable intentions. Don't assume all viruses are written for full sized computers. Raspberry Pis tend to have a reasonable amount of processing power and are often left running wtih very little to do. Recently viruses have been showing up that were written specifically to log into Raspberry Pis using the default user name and password and use their processing power to mine crypto currencies.

So, the first thing we are going to do is change the password. Open up a terminal window and type

pi@raspberrypi:~ $ sudo passwd

You will be prompted to enter your new password. Type in your new password, and your Pi will be that much more secure from unwanted visitors.

Connecting to WiFi

Next, let's connect the Pi Zero W to the internet. If you have a Pi Zero, you will need to add a Wifi dongle to your board's USB port (you may need a USB hub at this point). The Pi Zero W has built in WiFi, so you will not need any external WiFi dongles.

To enable WiFi on your Pi, look at the upper right corner of the Desktop, and left click the WiFi icon. You should see a list of available networks. Select the one you want. If it is a secured network, it will prompt you for a password. Enter the network password, and press OK. Give it a few seconds, and you should be connected. The WiFi symbol on the Desktop will change its appearance once connected. If you setup WiFi in Noobs, this information will already be saved. Adding WiFi isn't strictly necessary, but you will need internet access if you plan on doing updates.

Update Software

The last thing we are going to do is to update all the software packages on the board. Packages are constantly updated, and no one wants to be left behind. Luckily, Linux uses a package manager. All we have to do is tell our package manager to update everything, and then sit back and watch. Let's go over a few of the commands we'll be using. Go ahead and open the terminal, if it isn't already open. Type the following.

pi@raspberrypi:~ $ sudo apt-get update

This will go fetch the latest package information and tell the package manager what needs to be updated.

  • sudo (also known as super user) is a command that you will see a lot, specifically with high security commands. It makes sure you have the correct privileges. Depending on settings, it may or may not ask you for a password.

  • apt-get is the package manager and update is the command we are giving it.

Raspberry

pi@raspberrypi:~ $ sudo apt-get upgrade

This will download and upgrade all the packages. Please note that this upgrade will take a while. It will also prompt you if this is really what you want to do, the correct answer is 'Y'.

pi@raspberrypi:~ $ sudo shutdown -r now

  • shutdown will shutdown the machine. -r tells it to reboot after shutting down, and now tells it to do so now (15 would tell the machine to shutdown in 15 minutes).

What happens if you don't type in sudo? Linux will give you an error saying you don't have permission to do something. Generally if you see that error stop for a second and think if you really know what you are doing and want to do it. If you do, then type sudo in front of your command, and try again.

Other Useful Linux Commands

A few other useful commands for use in the terminal command line:

  • pwd - Print Working Directory, if you not sure what folder you are in this will tell you where you are in the filesystem.

  • ls - List, this will show you the contents of the folder. To show all files, including hidden ones, type ls -a to show all files/folders. Alternatively, typing ls -al will show you all files/folders as well as their permission settings.

  • cd - this is how you change directories. cd foldername will move you to that folder. cd .. will back you up one level. cd ~ will take you back to your home directory.

  • passwd - this will allow you to change your password

  • man - this stands for manual. Type man before a command to get a summary of how to use it.

  • nano - this will open a basic text editor that is fairly easy to use.

At this point you should be interacting with your Raspberry Pi like you would any other computer. You can teach yourself the finer points of Linux, learn Python, program the GPIO pins, setup a minecraft server, build a network storage system, game console, or media center, or just surf the web.

Resources and Going Further

Raspberry Pi Resources

  • Etcher - MacOS, Windows and Linux application for writing .img files to SD cards.
  • ApplePi Baker - MacOS application for writing .img files to SD cards.

Looking to make the Raspberry Pi Zero W a dongle? Check out the Pi Zero USB Stem:

For more Raspberry Pi fun, check out these other great SparkFun tutorials.

FLIR Lepton Hookup Guide

See the invisible world of infrared radiation using the FLIR Dev Kit and Raspberry Pi.

Bark Back Interactive Pet Monitor

Monitor and interact with pets through this dog bark detector project based on the Raspberry Pi!

Preassembled 40-pin Pi Wedge Hookup Guide

Using the Preassembled Pi Wedge to prototype with the Raspberry Pi B+.

PiRetrocade Assembly Guide

Build your very own retro gaming controller with a Raspberry Pi using the SparkFun PiRetrocade Kit!