Book Image

Raspberry Pi Zero Cookbook

Book Image

Raspberry Pi Zero Cookbook

Overview of this book

The Raspberry Pi Zero, one of the most inexpensive, fully-functional computers available, is a powerful and revolutionary product developed by the Raspberry Pi Foundation. The Raspberry Pi Zero opens up a new world for the makers out there. This book will give you expertise with the Raspberry Pi Zero, providing all the necessary recipes that will get you up and running. In this book, you will learn how to prepare your own circuits rather than buying the expensive add–ons available in the market. We start by showing you how to set up and manage the Pi Zero and then move on to configuring the hardware, running it with Linux, and programming it with Python scripts. Later, we integrate the Raspberry Pi Zero with sensors, motors, and other hardware. You will also get hands-on with interesting projects in media centers, IoT, and more.
Table of Contents (17 chapters)
Raspberry Pi Zero Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Connecting to displays and changing the configuration settings


The Raspberry Pi Zero is as capable as its predecessors, offering full HDMI video output. The ports are miniaturized, but that doesn't stop you from connecting your Zero to an LCD monitor. Here's how!

Getting ready

Now that you have your USB set up, your final step is getting video output. If you went with the video RCA hack, you can use the HDMI port or RCA video to get going. For HDMI, you'll need a micro-HDMI to standard HDMI adapter (and standard HDMI cable), or an HDMI cable that has one end micro and the other end standard.

A typical standard-to-micro HDMI adapter looks like this:

Standard-to-micro HDMI adapter

We now have our HDMI adapter and cable connected, the SD card installed, and the USB OTG adapter ready to go:

Pi connected to USB OTG and HDMI

How to do it...

  1. Confirm that the SD card is inserted and that your video and USB connections are set, and connect the micro-USB power to an adapter. If you started with NOOBS, you will be taken to the OS selection screen. Right now, there isn't very much to select from. The primary reason is that the Raspberry Pi Zero doesn't yet have Internet capability, so a list of available operating systems cannot be retrieved. For now, it is as easy as clicking on the checkbox for Raspbian and the Install button in the top left. From there, you are a few minutes from your new Raspberry Pi Zero desktop!

  2. Once you click on Install, NOOBS takes care of the rest and sets up a brand new default Raspbian system on your SD card. The system will start quickly and take you right to the installation screen:

    NOOBS OS selection screen

  3. When you select Install, NOOBS will take care of the rest and prepare your card with the Raspbian operating system:

    NOOBS Raspbian setup

  4. After this is complete, the installer will have you click to reboot, after which you will be taken right into Raspbian.

    Note

    If you started by using a Raspbian image instead of NOOBS, you will jump right into Raspbian Linux, skipping over the NOOBS setup section.

Initial Pi configuration

  1. The first thing you want to jump into is initial configuration. The fastest way to start that is by opening a terminal window. That's the little computer screen icon three icons to the right of the Menu button:

    The Terminal icon is just to the right of the File Cabinet

    Click on that and type this command:

              sudo raspi-config
    

    The Terminal screen - you'll be here a lot

  2. If you are prompted for a password, the initial password for user pi is raspberry. The Raspberry Pi configuration tool contains several options:

    raspi-config main options

  3. Let's start with option 1, Expand Filesystem. This will extend all of the space that is available on the SD card after making the image. After you select it, the screen will move back to the terminal, run some more commands, and come back to the configuration utility with a report:

    Partition resize success

  4. Next, let's change the default password of the pi user. Select the second option, and you will be prompted to enter and verify a new password.

    Note

    It is a very smart move to change the default user for pi or deactivate that user entirely. As you start playing with your Pi and making it more accessible to the Internet, you also make it more susceptible to hackers and bots. Since everyone knows the default login and password to a Raspbian installation, leaving them as the default when having them open to the Internet will almost certainly lead to unauthorized access and your work being stolen, altered, or destroyed.

    Another good option to take care of right away are Internationalization options. You can set your local time zone and keyboard type in this section. You'll know right away whether your Pi is set to the wrong keyboard layout when you start trying special characters.

  5. Finally, before rebooting, let's go into Advanced Options and pick the fourth option, SSH. Enable the SSH server. This will allow you to use the Raspberry Pi Zero from any computer on the network, once you get it on the network:

    Advanced options menu

The table below shows the options available in raspi-config and what they are used for:

Number

Raspi-config option

Function

Notes

1

Expand Filesystem

Extends all available space on the SD card

Run after initial boot

2

Change User PW

Changes the password for the pi user

Run after initial boot

3

Boot Options

Gives you different options to boot to desktop, with or without login

Covered in the next section

4

Wait for Network @ Boot

Waits to boot the Pi until a network has become available

Recommend keeping set to No

5

Internationalization Options

Settings for locale, time zone, and keyboard

Run after initial boot

6

Enable Camera

Enables the camera port on the Raspberry Pi

Enable if you have a camera

7

Add to Rastrack

Adds your Raspberry Pi to the Rastrack database

Optional, register at http://rastrack.co.uk

8

Overclock

Increase the maximum speed of the processor

Covered in next section; sadly doesn't work on the Zero

9

Advanced Options

Several different advanced configuration options

Enable SSH after initial boot.

0

About raspi-config

Information about the configuration utility