In this section, we will solder some headers onto the Raspberry Pi, load the OS onto a micro SD card, and fire the Raspberry Pi Zero for the first example.
The setup of the Raspberry Pi Zero
Soldering the GPIO headers
In this book, we will discuss the different aspects of Python programming using the Raspberry Pi's GPIO pins. The Raspberry Pi Zero ships without the GPIO header pins. Let's go ahead and solder the GPIO pins. We have also uploaded a video tutorials to this book's website that demonstrates soldering the headers onto the Raspberry Pi Zero.
As mentioned before, the Raspberry Pi's GPIO section consists of 40 pins. This is arranged in two rows of 20 pins each. We will need either two sets of 20-pin male headers or a 20-pin double-row male header. These are available from vendors such as Digikey and Mouser. The headers for the Raspberry Pi are also sold as a kit by vendors like the Pi Hut (https://thepihut.com/collections/raspberry-pi-zero/products/raspberry-pi-zero-essential-kit).
In order to solder the headers onto the Raspberry Pi Zero, arrange the headers on a breadboard, as shown in the following figure:
Perform the following steps:
- Arrange the Raspberry Pi on top of the headers upside down.
- Gently hold the Raspberry Pi (to make sure that the headers are positioned correctly while soldering) and solder the headers onto the Raspberry Pi.
- Inspect the board to ensure that the headers are soldered properly and carefully remove the Raspberry Pi Zero off the breadboard.
We are all set to make use of the GPIO pins in this book! Let's move on to the next section.
Enclosure for the Raspberry Pi Zero
Setting up a Raspberry Pi zero inside an enclosure is completely optional but definitely useful while working on your projects. There are a plenty of enclosures sold by vendors. Alternatively, you may download an enclosure design from Thingiverse and 3D print them. We found this enclosure to suit our needs at http://www.thingiverse.com/thing:1203246 as it provides access to the GPIO headers. 3D printing services such as 3D Hubs (https://www.3dhubs.com/) would print the enclosure for a charge of $9 via a local printer. Alternately, you can also use predesigned project enclosures or design one that can be constructed using plexiglass or similar materials.
OS setup for the Raspberry Pi
Let's go ahead and prepare a micro SD card to set up the Raspberry Pi Zero. In this book, we will be working with the Raspbian OS. The Raspbian OS has a wide user base, and the OS is officially supported by the Raspberry Pi Foundation. Hence, it is easier to find support on forums while working on projects as more people are familiar with the OS.
micro SD card preparation
If you had purchased a micro SD card that comes pre-flashed with the Raspbian New Out of the Box Software (NOOBS) image, you may skip the micro SD card preparation:
- The first step is downloading the Raspbian NOOBS image. The image can be downloaded from https://www.raspberrypi.org/downloads/noobs/.
- Format your SD card using the SD Card Formatter tool. Make sure that the FORMAT SIZE ADJUSTMENT is ON as shown in the snapshot (available from https://www.sdcard.org/downloads/formatter_4/index.html):
- Extract the downloaded ZIPÂ file and copy the contents of the file to the formatted micro SD card.
- Set up the Raspberry Pi (not necessarily in the same order):
- Interface the HDMI cable from the monitor via the mini HDMI interface
- USB hub via the USB OTG interface of the Raspberry Pi Zero
- Micro-USB cable to power the Raspberry Pi Zero
- Plug in a Wi-Fi adapter, a keyboard, and a mouse to the Raspberry Pi Zero
- Power up the Raspberry Pi, and it should automatically flash the OS onto the SD card and launch the desktop at startup.
- The first step after startup is changing the Raspberry Pi's password. Go to menu (the Raspberry Pi symbol located at the top-left corner) and select Raspberry Pi Configuration under Preferences.
- Under the System tab, change the password:
- Under the Localisation tab, change the locale, time zone, and keyboard settings based upon your region.
- When the installation is complete, connect the Raspberry Pi Zero to the wireless network (using the wireless tab on the top right).
- Let's launch the command-line terminal of the Raspberry Pi to perform some software updates.
- Run the following commands from the command-line terminal:
sudo apt-get update
sudo apt-get upgrade
The OS upgrade should complete within a couple of minutes.