Search icon
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
$38.99
Book Oct 2016 196 pages 1st Edition
eBook
$29.99 $20.98
Print
$38.99
Subscription
$15.99 Monthly
eBook
$29.99 $20.98
Print
$38.99
Subscription
$15.99 Monthly

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
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 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

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
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
Configuring Your Raspberry Pi Zero Board Chevron down icon Chevron up icon
Measure Data Using Your Raspberry Pi Zero Board Chevron down icon Chevron up icon
Building a Smart Home Thermostat Chevron down icon Chevron up icon
Controlling Appliances fromthe Raspberry Pi Zero Chevron down icon Chevron up icon
Making a Smart Plug with the Raspberry Pi Zero Chevron down icon Chevron up icon
Sending Notifications using Raspberry Pi Zero Chevron down icon Chevron up icon
Use the Raspberry Pi Zero to Build a Security System Chevron down icon Chevron up icon
Monitor Your Home from the Cloud Chevron down icon Chevron up icon
Control Appliances from Anywhere Chevron down icon Chevron up icon
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

Filter icon Filter
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%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela