Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Building Smart Homes with Raspberry Pi Zero
Building Smart Homes with Raspberry Pi Zero

Building Smart Homes with Raspberry Pi Zero: Build revolutionary and incredibly useful home automation projects with the all-new Pi Zero

By Marco Schwartz
R$173.99 R$80.00
Book Oct 2016 196 pages 1st Edition
eBook
R$173.99 R$80.00
Print
R$217.99
Subscription
Free Trial
eBook
R$173.99 R$80.00
Print
R$217.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now
Table of content icon View table of contents Preview book icon Preview Book

Building Smart Homes with Raspberry Pi Zero

Chapter 1. Configuring Your Raspberry Pi Zero Board

In the first chapter of this book, we are going to go through all the steps that are required to configure your Raspberry Pi Zero board so you can use it for all the projects we will see in this book.

First we will look at the list of components that are required to use the board. Then, we will install the Raspbian distribution, which will be the operating system we will use throughout this book, on the board. Finally, we'll see how to configure the board for remote, and how to install the Node.js framework that we will use in nearly all the projects of the book. Let's start!

Introducing the Raspberry Pi Zero board


The Raspberry Pi Zero is a board that was introduced in 2015, and the goal was to make a low-cost ($5), small-format board with most of the functionalities of the original Raspberry Pi board.

The following is an image of the Zero board:

In the center of the board, you will find the same System-on-a-Chip (SoC) as the original Raspberry Pi board, with a 1-GHz single-core processor, 512 MB of RAM, and a graphical processing unit.

The board has several inputs and outputs, like the 40-pin GPIO connector that we will use through this whole book to connect the board to sensors and other components.

There are also two USB ports (one for power, one for communication), one mini-HDMI port, and one SD card slot to put the operating system and other files in.

The power consumption of the board was also reduced compared to the first board, going from 1.5W to 0.8W.

Required components for the Zero board


Even if the Raspberry Pi Zero board has a very small form factor, it actually can't be used alone, at least for the configuration step. Therefore, we are going to need a lot of additional components for all the projects of this book, and this is what I wanted to go through in this section.

The first thing you will need for your Pi Zero board is a micro-USB to USB converter, so you can plug regular USB devices into your board. This is an image of the cable I used for my Pi board:

Then, you will need some way to connect your Raspberry Pi Zero board to a computer screen. To do so, you will need a mini-HDMI to HDMI adapter:

In order to connect more than one device to the board, you will also need a regular USB hub:

Later in this chapter, we are going to look at how to use the Raspberry Pi board remotely from your computer, so you don't need to always have it connected to an external screen. However, to begin with, you will need a keyboard and mouse to use it:

Tip

I recommend using a keyboard with a small track pad as well.

The Raspberry Pi Zero board doesn't come with onboard storage. Therefore, you will need to use a micro SD card to store the operating system. I recommend using at least an 8-GB SD card:

At some point, we are going to connect the Raspberry Pi Zero board to the Internet. We'll also need to connect it to your local network, so you can access it remotely. To do so, I recommend using a simple Wi-Fi USB dongle:

Of course, you will need other components to use the Raspberry Pi Zero board that I haven't included here as usually, they are already on everyone's desk. For example, you will need a screen with an HDMI input to use the board. You will also need a micro-USB power supply, for example, the one you are using to charge your phone. The Raspberry Pi foundation says it should work with a power supply that can deliver at least 1A, but a 2A power supply is recommended.

Assembling the different components


Let's now look at how to assemble the required components so we can get started with your Raspberry Pi:

  1. First, insert the micro-USB to USB adapter cable into one of the USB ports of the Pi (not the PWR one), and also plug the mini-HDMI cable to the Pi.

  2. Then, connect all your required USB devices (for example, the Wi-Fi dongle) to the USB hub, and connect the USB to the Pi. Also, connect the Pi to an external screen using an HDMI cable.

  3. This is how it should look when you are done, not showing the connections to the screen or the hub:

  4. At this point, don't connect it to the power yet—we first need to install Raspbian (the operating system) on the SD card.

Installing Raspbian


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, which is an operating system based on Debian that was specifically made for Raspberry Pi.

In order to install the Raspbian operating system on your Pi, the first step is to download the latest Raspbian image from the official Raspberry Pi website:

https://www.raspberrypi.org/downloads/raspbian/

Next, insert the micro SD card into your computer using an adapter (an adapter is usually given with the SD card). To actually configure the SD card, it's best to refer to the official installation guides. If you use Windows, please refer to the following URL:

https://www.raspberrypi.org/documentation/installation/installing-images/windows.md

If you are using OS X, please refer to the following:

https://www.raspberrypi.org/documentation/installation/installing-images/mac.md

Finally, if you are using Linux, you can refer to the following:

https://www.raspberrypi.org/documentation/installation/installing-images/linux.md

Now, once 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.

Then, after a while, you should see the desktop of your freshly installed Raspbian operating system:

If you can see this screen, congratulations; you now have a fully functional Raspberry Pi Zero board. Throughout the rest of this chapter, we are going to see how to configure the board so it can be accessed remotely, and how to install the Node.js framework on it.

Configuring the board for remote access


At the end of this chapter, you want to be able to access the board from your own computer, without having it connected to an external screen.

The first step is to connect the Raspberry Pi board to your local Wi-Fi network. If you connected a Wi-Fi dongle to the Pi, you should see the Wi-Fi icon at the top of your Pi desktop. Click on it, and select your Wi-Fi network:

You will then be asked to enter the password for your network, and a few seconds later, you should be connected to your local Wi-Fi network and to the Internet.

Next, we need to enter the Raspberry Pi configuration panel so we can set some essential settings. You can find the Raspberry Pi Configuration tool inside the main Menu:

Inside the configuration tool, first press on Expand Filesystem:

This will make sure that the Pi now has access to all the space available on the SD card. Also, click on the Interfaces tab and check that SSL is checked:

Inside the same configuration tool, you can also give a network name to your Pi. I simply called mine pizero.

We are now going to perform some tests from your computer to make sure that Raspberry Pi is correctly configured for remote access and that it has access to the Internet.

To do so, open a terminal window on your computer (or use PuTTY if you are using Windows), and type the following:

ssh pi@pizero.local

This should initiate a connection to your Pi board and ask for your password. Once you type in your password, you should now be connected to the Pi board. If that doesn't work at this point, try replacing the name of your Raspberry Pi with the IP address of the board (you can get this by typing ifconfig inside a Terminal on the Pi itself).

Then, from your computer, type the following:

sudo apt-get update

Then type the following command:

sudo apt-get upgrade

This will upgrade your Pi board by downloading all the latest packages from the official Raspberry Pi repository, so it's a great way to make sure that your board is connected to the Internet.

Installing Node.js


To finish this chapter, we are going to install Node.js, which is a powerful framework that we will use to run most of the applications that we are going to see inside this book. Luckily for us, installing Node.js on Raspberry Pi is really simple.

First, log into your Raspberry Pi via SSH. We are going to quickly check that Node.js was not installed with the Linux image. To do so, type the following:

node -v

If this returns the version of Node.js, you can stop there. If it returns an error, you will have to install it manually. To do so, first type the following:

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -

After that, type the following command, which will install Node.js:

sudo apt-get install -y nodejs

Finally, install some additional tools with the following:

sudo apt-get install -y build-essential

You can now test that Node.js is correctly installed by typing the following:

node -v

Congratulations, you now have a fully configured Raspberry Pi Zero! In the next chapter, we are going to build your first application using the Zero board and learn how to measure data from sensors.

Summary


In this first chapter of this book, we saw how to configure our Raspberry Pi Zero board so we can use it in later chapters of this book. We saw what components were needed for the Pi, and how to install Raspbian so we can run software on our board. Finally, we installed Node.js, which we will use in the whole book to run home automation projects on our Pi.

In the following chapter, we are going to dive into the core topic of the book by learning how to measure data from a sensor.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Create and program home automation projects using the Raspberry Pi Zero board
  • Connect your Raspberry Pi Zero to a cloud API, and then build a cloud dashboard to control your devices
  • Integrate all the projects into a complex project to automate key aspects of your home: data monitoring, devices control, and security

Description

The release of the Raspberry Pi Zero has completely amazed the tech community. With the price, form factor, and being high on utility—the Raspberry Pi Zero is the perfect companion to support home automation projects and makes IoT even more accessible. With this book, you will be able to create and program home automation projects using the Raspberry Pi Zero board. The book will teach you how to build a thermostat that will automatically regulate the temperature in your home. Another important topic in home automation is controlling electrical appliances, and you will learn how to control LED Lights, lamps, and other electrical applications. Moving on, we will build a smart energy meter that can measure the power of the appliance, and you’ll learn how to switch it on and off. You’ll also see how to build simple security system, composed of alarms, a security camera, and motion detectors. At the end, you will integrate everything what you learned so far into a more complex project to automate the key aspects of your home. By the end, you will have deepened your knowledge of the Raspberry Pi Zero, and will know how to build autonomous home automation projects.

What you will learn

[*] Learn how to measure and store data using the Raspberry Pi Zero board [*] Control LED lights, lamps, and other electrical applications [*] Send automated notifications by e-mail, SMS, or push notifications [*] Connect motion detectors, cameras, and alarms [*] Create automated alerts using Raspberry Pi Zero boards [*] Control devices using cloud-based services [*] Build a complete home automation system using Pi Zero

Product Details

Country selected

Publication date : Oct 26, 2016
Length 196 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781786466952
Vendor :
Raspberry Pi
Category :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Oct 26, 2016
Length 196 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781786466952
Vendor :
Raspberry Pi
Category :

Table of Contents

17 Chapters
Building Smart Homes with Raspberry Pi Zero Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
About the Author Chevron down icon Chevron up icon
About the Reviewer Chevron down icon Chevron up icon
www.PacktPub.com Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
1. Configuring Your Raspberry Pi Zero Board Chevron down icon Chevron up icon
2. Measure Data Using Your Raspberry Pi Zero Board Chevron down icon Chevron up icon
3. Building a Smart Home Thermostat Chevron down icon Chevron up icon
4. Controlling Appliances fromthe Raspberry Pi Zero Chevron down icon Chevron up icon
5. Making a Smart Plug with the Raspberry Pi Zero Chevron down icon Chevron up icon
6. Sending Notifications using Raspberry Pi Zero Chevron down icon Chevron up icon
7. Use the Raspberry Pi Zero to Build a Security System Chevron down icon Chevron up icon
8. Monitor Your Home from the Cloud Chevron down icon Chevron up icon
9. Control Appliances from Anywhere Chevron down icon Chevron up icon
10. Building a Home Automation System with Raspberry Pi Zero Boards Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Top Reviews
No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.