Chapter 1. Getting Started with Raspberry Pi Zero

Before building several projects for a home security system and the control of domestic appliances by electronically controlled systems, in this chapter, we're going to go into an initial configuration and prepare our Raspberry Pi Zero to work in a network, so you can use it for all the projects we will see in this book.

Before we go through the projects, build our network with the devices, and connect our sensor to the boards, it's important to understand the configuration of the Raspberry Pi. The main idea of this chapter is to explain how to set up your Raspberry Pi Zero; we will cover the following topics:

  • Setting up Raspberry Pi Zero
  • Preparing the SD card
  • Installing the Raspbian operating system
  • Configuring your Raspberry Pi Zero with a serial console cable
  • Accessing the network remotely
  • Accessing via remote desktop
  • Configuring a web server

Setting up Raspberry Pi Zero

The Raspberry Pi is a low-cost board dedicated to purpose projects. Here, we will use a Raspberry Pi Zero board. Take a look at the following link:  https://www.adafruit.com/products/2816. I used this board.

In order to make the Raspberry Pi work, we need an operating system that acts as a bridge between the hardware and the user. This book uses the Raspbian Jessy, which can be downloaded from https://www.raspberrypi.org/downloads/. At this link, you will find all of the information you need to download all the pieces of software necessary to use with your Raspberry Pi to deploy Raspbian. You need a micro SD card of at least 4 GB.

The kit that I used to test the Raspberry Pi Zero includes all the necessary things for installing everything and getting the board ready:

Setting up Raspberry Pi Zero

Preparing the SD card

The Raspberry Pi Zero only boots from an SD card and cannot boot from an external drive or USB stick. For this book, it's recommended to use a 4 GB micro SD card.

Installing the Raspbian operating system

There are many operating systems that are available for the Raspberry Pi board, most of which are based on Linux. However, the one that is usually recommended is Raspbian, is an operating system based on Debian, which was specifically made for Raspberry Pi.

In order to install the Raspbian operating system on your Pi, follow the next steps:

  1. Download the latest Raspbian image from the official Raspberry Pi website: https://www.raspberrypi.org/downloads/raspbian/ 
  2. Next, insert the micro SD card into your computer using an adapter. (An adapter is usually given with the SD card.)
  3. Then download Win32DiskImager from https://sourceforge.net/projects/win32diskimager/.

    You will see the following files, as shown in the screenshot, after downloading the folder:

    Installing the Raspbian operating system
  4. Open the file image, select the path where you have the micro SD card, and click on the Write button.
  5. After a few seconds,you have Raspbian installed on your SD card; insert it into Raspberry Pi and connect the Raspberry Pi board to the power source via the micro-USB port.

    In the following screenshot, you can see the progress of the installation:

    Installing the Raspbian operating system

Debugging your Raspberry Pi Zero with a serial console cable

In this section, we will look at how to communicate, the Raspberry Pi Zero from a computer using a TTL serial converter. We can do this debugging with a serial console cable connected to the computer using the USB port. We communicate with the board with a serial cable, because if we want to send commands from our computer to the board, it's necessary to communicate using this cable. You can find the cable at https://www.adafruit.com/products/954:

Debugging your Raspberry Pi Zero with a serial console cable

It’s important to consider that the cable uses 3.3 volts, but we don’t care because we’re using the cable from Adafruit. It is tested to work at this level of voltage.

You need to follow the next steps in order to install and communicate with your Raspberry Pi Zero:

  1. It's necessary that you have a free USB port on your computer.
  2. We need to install the driver for the serial console cable so that the system can recognize the hardware. We recommend that you download the driver from https://www.adafruit.com/images/product-files/954/PL2303_Prolific_DriverInstaller_v1_12_0.zip.
  3. We use an interface (console software), called PuTTY, running on a Windows computer; so we can communicate with our board, the Raspberry Pi. This software can be downloaded and installed from http://www.putty.org/.
  4. For the connections, we need to connect the red cable to  5 volts, the black cable to ground, the white cable to the TXD pin, and the green cable to the RXD pin on the Raspberry Pi Zero.
  5. The other side of the cable connects the plug to the USB port.

This is an image of the connections; it's for the hardware configuration:

Debugging your Raspberry Pi Zero with a serial console cable

Testing and accessing the serial COM interface

Once the driver is installed, we have here the Port COM, which is already installed:

Tip

This configuration is for Windows installation; if you have different operating system, you need to do different steps.

How get the Device Manager screen: On your windows PC, click on the Start icon, go to Control Panel, select System, and then click on Device Manager.

In the following screenshot, you can see the device manager of the USB serial port:

Testing and accessing the serial COM interface
  1. Open the terminal in PuTTY, and select Serial Communication as COM3, Speed as 115200, Parity as None, and Flow Control as None; click on Open:
    Testing and accessing the serial COM interface
  2. When the blank screen appears, press Enter on your keyboard:
    Testing and accessing the serial COM interface
  3. This initiates a connection to your Pi board and asks for your username and password; you will see a screen like the following screenshot, with the authentication login:
    Testing and accessing the serial COM interface
  4. The default username for the Raspberry Pi Zero is pi, and the password is raspberry:
    Testing and accessing the serial COM interface
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.28.202