32,39 €
Build DIY wireless projects using the Raspberry Pi Zero W board
If you are a hobbyist or an enthusiast and want to get your hands on the latest Raspberry Pi Zero W to build exciting wireless projects, then this book is for you. Some prior programming knowledge, with some experience in electronics, would be useful.
The Raspberry Pi has always been the go–to, lightweight ARM-based computer. The recent launch of the Pi Zero W has not disappointed its audience with its $10 release. "W" here stands for Wireless, denoting that the Raspberry Pi is solely focused on the recent trends for wireless tools and the relevant use cases. This is where our book—Raspberry Pi Zero W Wireless Projects—comes into its own.
Each chapter will help you design and build a few DIY projects using the Raspberry Pi Zero W board. First, you will learn how to create a wireless decentralized chat service (client-client) using the Raspberry Pi's features?. Then you will make a simple two-wheel mobile robot and control it via your Android device over your local Wi-Fi network. Further, you will use the board to design a home bot that can be connected to plenty of devices in your home. The next two projects build a simple web streaming security layer using a web camera and portable speakers that will adjust the playlist according to your mood. You will also build a home server to host files and websites using the board. Towards the end, you will create free Alexa voice recognition software and an FPV Pi Camera, which can be used to monitor a system, watch a movie, spy on something, remotely control a drone, and more.
By the end of this book, you will have developed the skills required to build exciting and complex projects with Raspberry Pi Zero W.
A step-by-step guide that will help you design and create simple yet exciting projects using the Raspberry Pi Zero W board.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 215
Veröffentlichungsjahr: 2017
BIRMINGHAM - MUMBAI
Copyright © 2017 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: August 2017
Production reference: 1230817
ISBN 978-1-78829-052-4
www.packtpub.com
Author
Vasilis Tzivaras
Copy Editors
Ulka Manjrekar
Laxmi Subramanian
Reviewer
Taifoun Sianko
Project Coordinator
Kinjal Bari
Commissioning Editor
Vijin Boricha
Proofreader
Safis Editing
Acquisition Editor
Prachi Bisht
Indexer
Rekha Nair
Content Development Editor
Eisha Dsouza
Graphic
Kirk D'Penha
Technical Editor
Naveenkumar Jain
Production Coordinator
Shantanu Zagade
Vasilis Tzivaras is a computer science engineer who lives in Greece. He is the author of the Building a Quadcopter with Arduino and is also the chair of the IEEE University of Ioannina Student Branch. He is currently working on projects relevant to robotics, home automation, and smart security systems. He is also an enthusiast about Internet of Things technology and drones.
Taifoun Sianko is a computer science graduate from university of Ioannina. He just started his career as software developer. During his study, he has been studied data structures, compilers and algorithms. His love for development and mobiles pushed him to begin Android development and UI design as freelancer. He also makes his own automation based on Arduino and Raspberry Pi.
For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1788290526.
If you'd like to join our team of regular reviewers, you can e-mail us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Introduction to Raspberry Pi Zero W
The Raspberry Pi family
Raspberry Pi Zero W
Specifications
Camera support
Accessories
An OTG cable
PowerHub
A GPIO header
MicroSD card and card adapter
An HDMI to mini HDMI cable
An HDMI to VGA cable
RCA jacks
A Raspberry Pi Zero W case
Distributions
The NOOBS distribution
The Raspbian distribution
Distributors
Common Issues
Debugging steps
MicroSD card issue
Case protection
Summary
IoT and Networking
Internet of Things
Basic communication protocols
Internet protocols
IoT Protocols
Bluetooth
Zigbee
Z-Wave
6LowPAN
NFC
Wi-Fi
LoRaWAN
Connecting your Pi
Pi Zero W setup
The internet
Local network
Port forwarding
Connecting to the internet
Networking administration
Connect for command execution
Automatic authentication
Connecting for file transfer
FileZilla
SCP
Secure the Raspberry Pi and remove others
Firewall
Summary
Chatbot
User input
Server installation
The chatbot development
Chat services
Chatfuel
Frow XO
Converse
Facebook messenger
Google cleverbot
Secure data transfer
Summary
Mobile Robot
Fundamentals of robotics
DC motors
Torque
Wheel
Encoders
Hardware overview
DC motor and wheels
Encoder
Arduino microcontroller
Motorshield
Servo
Ultrasonic sensor
Bluetooth
Breadboard
Battery
Other components
Motor soldering
Programming the controller
Basic concept
Controller development
Future ideas
Four motor mobile robots
Summary
Home Bot
Introduction to home bots
Socket programming
Simple client-server communication
Simple server
Simple client
Advanced client-server communication
Advanced server
Advanced client
Home automation
Summary
Security Camera
Installing a camera
Installing MotionPie
Set up multiple network cameras
Connecting a camera outside of your local network
Configuring MotionPie settings
General settings
Wireless network
Video device
File storage
Text Overlay
Video Streaming
Still images
Motion Detection
Motion Movies
Motion Notifications
Working Schedule
Installing OpenCV
Face recognition
Summary
Portable Speakers
Market speakers
Software setup
Networking
MusicBox
Audio
Music files
Online music services
Security
Sound players
Alsamixer
Connect your speaker
Music on Pi
Mood selection
Hardware
Code
Summary
WebPi Hosting
Web hosting
Definition
Hosting services
Domain name
DNS
Setup
Client-server communication
Client request
Communication protocols
Server response
Proxy servers and caching
Website development
XAMPP/LAMPP
Accessing the website
Remote control
SSH
SSH clients
Windows
Linux
Automating the SSH procedure
SFTP
FileZilla
Terminal
Networking
Router access
Port forwarding
Home IP address
Security layers
Security
Router Interface
Computer
ISP
Summary
AlexaPi
Creating an Amazon Developer account
Setting up Raspberry Pi
Installing Alexa
Voice recognition
Official Alexa vs AlexaPi
Network administration
Summary
WeatherPi
The Sense HAT module
Weather station
Initial State
Startup
Summary
The new member of the Raspberry Pi family is equipped with wireless and Bluetooth extensions. Through this book you can learn and create awesome projects that allows you to explore the capabilities of the new board. With only $10 you can develop skills and be part of a new world where you can develop your robots, your home automation systems, increase your security layers in your home and much more.
Chapter 1, Introduction to Raspberry Pi Zero W, will introduce the new board with the wireless extension. We will mention some modules that you can buy with and give a general overview of the new board.
Chapter 2, IoT and Networking, will talk about Internet of Things. Raspberry Pi Zero W is very small, which makes it a perfect board for IoT projects. It is also equipped with Bluetooth Low Energy (BLE), which minimizes the energy consumption. Lastly, we will give an introduction to networking and how you will interact with the board.
Chapter 3, Chatbot, will develop a chatbot. Chatbots are ubiquitous nowadays and usually consist of a client and a server. So we will start by creating a client and then end the chapter by implementing the server side. We will also mention some protocols that chatbots use.
Chapter 4, Mobile Robot, will be devoted to robotics. You will learn how to build a two-wheeled mobile robot, and through the chapter you will learn the fundamentals of robotics that are necessary skills for developing any kind of robot.
Chapter 5, Home Bot, explains how to build a home bot and automate your home with commands from a local website or your mobile phone. A general system of home automation will be implemented and described.
Chapter 6, Security Camera, will demonstrate the implementation of a security system. Adding a camera to your home makes it smarter, and you can always see and record what is going on.
Chapter 7, Portable Speakers, chapter is about music. Since the Raspberry Pi Zero W is quite small, it is pretty easy to make it portable and add some speakers to listen to your favorite music wherever you want. You only need a powerbank and you can get your music with you.
Chapter 8, WebPi Hosting, is about web hosting and developing. With the Raspberry Pi Zero W board you can host websites and develop simple sites to help you control your home and automate things. Through this chapter you will learn how to make a website, upload it to the Raspberry Pi, and publish it to the world.
Chapter 9, AlexaPi, is about the Alexa Voice Service (AVS) from Amazon. We will upload the AVS to our Raspberry Pi Zero W board and develop a system that allows us to control anything that is connected to the AVS. We can also, talk with Alexa and get answers in questions such as What time is it?
Chapter 10, WeatherPi, will develop a weathering station with which you can monitor your home or any place you want and get measurements of the temperature and the humidity of the place.
Even if it works in all operating systems, it is better to have a Linux operating system. You obviously need your basic Raspberry Pi Zero W kit with a camera. Furthermore, you need the SenseHAT module and a microphone or a headset. You also need Bluetooth speaker, and lastly, all the components necessary for the two-wheeled mobile robot.
If you are a hobbyist or an enthusiast who wants to get their hands on the latest Raspberry Pi Zero W and leverage it to build exciting wireless projects then, this book is for you. Prior programming knowledge with some experience in electronics would be useful.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Create a new file namedcpiand type the following command."
A block of code is set as follows:
[226314.048026] usb 4-2: new full-speed USB device number 82 using uhci_hcd [226314.213273] usb 4-2: New USB device found, idVendor=0a5c, idProduct=2763 [226314.213280] usb 4-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [226314.213284] usb 4-2: Product: BCM2708 Boot[226314.213] usb 4-2: Manufacturer: Broadcom
Any command-line input or output is written as follows:
man <linux-command>
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on theSavebutton."
Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
Log in or register to our website using your e-mail address and password.
Hover the mouse pointer on the
SUPPORT
tab at the top.
Click on
Code Downloads & Errata
.
Enter the name of the book in the
Search
box.
Select the book for which you're looking to download the code files.
Choose from the drop-down menu where you purchased this book from.
Click on
Code Download
.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR / 7-Zip for Windows
Zipeg / iZip / UnRarX for Mac
7-Zip / PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Raspberry-Pi-Zero-W-Wireless-Projects. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: https://www.packtpub.com/sites/default/files/downloads/RaspberryPiZeroWWirelessProjects_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under theErrata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at [email protected] with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.
Raspberry Pi Zero W is a new product from the Raspberry Pi Zero family. In early 2017, the Raspberry Pi community announced a new board with a wireless extension. It offers wireless functionality and now anyone can develop their own project without cables or other components. Comparing the new board with Raspberry Pi 3 Model B, we can easily see that it is much smaller, with many possibilities for the Internet of Things. However, what is a Raspberry Pi Zero W, and why do you need it? Let's go through the rest of the family and introduce the new board. In this chapter, we will cover the following topics:
An overview of the Raspberry Pi family
An introduction to the new Raspberry Pi Zero W
Distributions
Distributors
Common issues
As mentioned previously, Raspberry Pi Zero W is a new member of the Raspberry Pi family of boards. Throughout the years, Raspberry Pi has been evolving and has become more user-friendly with endless possibilities. Let's have a look at the rest of the family, so we can understand how the Pi Zero board is different.
Right now, the heavy board is named Raspberry Pi 3 Model B. It is the best solution for projects such as face recognition, video tracking, gaming, or anything else that is demanding:
This is the third generation of Raspberry Pi boards after Raspberry Pi 2 and has the following specifications:
A 1.2 GHz 64-bit quad core ARMv8 CPU
802.11 n wireless LAN
Bluetooth 4.1
Bluetooth Low Energy (BLE)
Like Pi 2, it also has:
1 GB RAM
4 USB ports
40 GPIO pins
Full HDMI port
Ethernet port
Combined 3.5 mm audio jack and composite video
Camera interface (CSI)
Display interface (DSI)
MicroSD card slot (now push-pull rather than push-push)
VideoCore IV 3D graphics core
The next board is Raspberry Pi Zero, in which Zero W is based, a small, low-cost power board able to do many things:
The specifications of this board are as follows:
1 GHz, single-core CPU
512 MB RAM
Mini HDMI port
Micro-USB OTG port
Micro-USB power
HAT-compatible 40-pin header
Composite video and reset headers
CSI camera connector (v1.3 only)
At this point, we should not forget to mention that apart from the boards mentioned previously, there are several other modules and components such as Sense Hat or Raspberry Pi Touch Display available that will work well for advanced projects.
The 7″ touchscreen monitor of Raspberry Pi gives users the ability to create all-in-one, integrated projects such as tablets, infotainment systems, and embedded projects:
The Sense HAT is an add-on board for Raspberry Pi made especially for the Astro Pi mission. The Sense HAT has an 8×8 RGB LED matrix, a five-button joystick and includes the following sensors:
Gyroscope
Accelerometer
Magnetometer
Temperature
Barometric pressure
Humidity
Stay tuned for new boards and modules at the official website https://www.raspberrypi.org.
Raspberry Pi Zero W is a small device that can be connected to either an external monitor or TV and of course, to the internet. The operating system varies, as there are many distributions on the official page and almost every distribution is based on Linux systems:
With Raspberry Pi Zero W, you have the ability to do almost everything from automation to gaming! It is a small computer that allows you to easily program with the help of GPIO pins and some other components such as a camera. Its possibilities are endless! In the next chapter, you will go through some awesome projects with this new board. Since almost all input and output on the Raspberry Pi Zero W board goes through GPIO pins, it is important to keep in mind a pinout diagram. The following is a pinout diagram of the Raspberry Pi Zero W board, which can be handy when soldering buttons or other types of sensors onto your Raspberry Pi board:
If you have bought a Raspberry Pi 3 Model B, you will be familiar with the Cypress CYW43438 wireless chip. It provides 802.11 n wireless LAN and Bluetooth 4.0 connectivity. The new Raspberry Pi Zero W is equipped with this wireless chip as well. The following are the specifications of the new board:
Dimensions:
65 mm × 30 mm × 5 mm
SoC:
Broadcom BCM 2835 chip
ARM11 at 1 GHz, single-core CPU
512 ΜΒ RAM
Storage:
MicroSD card
Video and Audio:
1080p HD video and stereo audio via mini HDMI connector
Power:
5V supplied via micro-USB connector
Wireless:
2.4GHz 802.11 n wireless LAN
Bluetooth:
Bluetooth classic 4.0 and Bluetooth Low Energy (BLE)
Output:
Micro-USB
GPIO:
40-pin GPIO, unpopulated
In the following image, we can see the new Raspberry Pi Zero W equipped with the previously mentioned specifications:
Notice that all components are at the top of the board, so you can easily choose your case without any problems and keep it safe. As far as the antenna is concerned, it is formed by etching away copper on each layer of the PCB. It may not be visible, as it is in other similar boards, but it works great and offers quite a lot of functionalities:
Also, the product is limited to only one piece per buyer and costs $10. You can buy a full kit with a MicroSD card, a case, and some extra components for about $45, or choose the full kit with a camera that contains a small camera component for $55.
Image processing projects, such as video tracking or face recognition, require a camera. In the next image, you can see the official camera support for Raspberry Pi Zero W. The camera can be easily mounted at the side of the board using a cable, similar to the Raspberry Pi 3 Model B board.
Depending on your distribution, you may need to enable the camera through the command line. More information on the usage of this module will be mentioned in the project chapters.
While building projects with the new board, there are some other gadgets that you might find useful to work with. The following is a list of some crucial components. Notice that if you buy a Raspberry Pi Zero W kit, it includes some of them. So, be careful and don't double upon them.
An OTG cable
PowerHub
A GPIO header
A MicroSD card and card adapter
An HDMI to mini HDMI cable
An HDMI to VGA cable
First of all, an OTG cable is always useful. You can use this cable to power your Raspberry Pi from a power bank or any other power source.
The second most important component is the PowerHub. A PowerHub is a device powered by a USB or external power source and produces four or more USB ports:
Next, you might find the GPIO header module handy. Since Raspberry Pi Zero W comes without soldered pins, it is useful to connect GPIO pins over and breadboard:
You might also need a MicroSD card adapter as not every computer has a MicroSD card slot for reading and writing data. It costs quite a few dollars but will save you time.
Unfortunately, the new Raspberry Pi Zero W does not have a normal HDMI port. It is a bit smaller, and you need the HDMI to mini HDMI cable to expand the port to a normal HDMI. Then, you are free to connect the port with any HDMI-compatible device. So, the next cable is necessary:
Since many monitors are not HDMI compatible, the HDMI to VGA cable allows you to connect the HDMI to mini HDMI cable with an external monitor or TV. When you need to view something on the monitor and it does not support HDMI, this cable is required:
Lastly, some TVs still use RCA jacks. With this module, you can connect the Pi board to the RCA jack on your TV by simply connecting the two wires, + (signal) and - (ground), of the module.
