Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Internet of Things Programming with JavaScript

You're reading from   Internet of Things Programming with JavaScript Get the best out of Arduino and Raspberry Pi Zero to develop Internet of Things projects using JavaScript

Arrow left icon
Product type Paperback
Published in Feb 2017
Publisher Packt
ISBN-13 9781785888564
Length 298 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ruben Oliva Ramos Ruben Oliva Ramos
Author Profile Icon Ruben Oliva Ramos
Ruben Oliva Ramos
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Getting Started with Raspberry Pi Zero 2. Connecting Things to the Raspberry Pi Zero FREE CHAPTER 3. Connecting Sensors - Measure the Real Things 4. Control-Connected Devices 5. Adding a Webcam to Monitor Your Security System 6. Building a Web Monitor and Controlling Devices from a Dashboard 7. Building a Spy Police with the Internet of Things Dashboard 8. Monitoring and Controlling Your Devices from a Smart Phone 9. Putting It All Together

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
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime