23,99 €
With Wearable-Tech Projects with the Raspberry Pi Zero, you will begin with learning how to install the required software for your upcoming projects. You will also learn how to control electronic devices with the GPIOZero Python library. Next, you will be creating some stylish wearable-tech projects such as a motion-reactive LED cap and a Tweet-activated LED T-shirt.
Toward the end of the book, you will be creating some useful health and fitness wearable-tech projects; these will help you monitor your heart rate, track your movements with GPS, and count your footsteps with your own pedometer.
By the end of the book, you will have created a range of wearable-tech projects and learned enough about your Raspberry Pi Zero that you should be able to adapt these projects further or come up with your own creations!
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 206
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: July 2017
Production reference: 1130717
ISBN 978-1-78646-881-9
www.packtpub.com
Author
Jon Witts
Copy Editor
Yesha Gangani
Reviewer
David Grainger
Project Coordinator
Judie Jose
Commissioning Editor
Vijin Boricha
Proofreader
Safis Editing
Acquisition Editor
Meeta Rajani
Indexer
Rekha Nair
Content Development Editor
Devika Battike
Graphics
Kirk D'Penha
Technical Editor
Mohd Riyan Khan
Production Coordinator
Aparna Bhagat
Jon Witts has been working within the IT industry since 2001, and specifically within Educational IT since 2004. He was introduced to Linux back in 2001, through his collaboration with two German artists who were visiting the arts organization he was then working with. Having studied both Fine Art and Educational Technology, he has sought to innovate with open and accessible digital technologies within his creative practice. Jon is happiest when deconstructing technology and finding its limits.
Jon has embedded within his school the use of Raspberry Pi computers as an integral part of the delivery of the school's Computer Science curriculum. Being a Raspberry Pi Certified Educator, Jon runs various school clubs and projects, such as a Raspberry Pi Robot Building club. Jon also organizes and runs Raspberry Jam events in the 2017 UK City of Culture, Kingston upon Hull.
David Grainger is a teacher of physics and IT since 1999. He is a graduate of physics from The University of Edinburgh and is currently the Head of Physics at Queen Margaret's school.
He has always maintained a passion for using technology and computers. He became a Raspberry Pi Certified Educator in 2015 and started a new Computer Science department.
He is the inaugural graduate of Raspberry Pi's Skycademy program and to date has successfully launched and recovered three Raspberry Pis to approximately 30 km into the stratosphere.
He has used Raspberry Pi to teach computer science to KS3s and ultimately GCSEs.
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 http://www.amazon.com/dp/1786468816.
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 will need
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
About the Raspberry Pi
What we will cover
A little history
The bill of parts
Installing our software
Using Etcher to copy our image
Connecting to GPIO headers
Hammer headers
Solder headers
Getting your equipment ready
Headless access
Enabling SSH access
Setting up your Wi-Fi network
Connecting to your Pi
SSH from Windows
SSH from macOS
SSH from Linux
Final setup
Changing your password
Changing the hour hostname
Installing basic software
Basic electronics
Wiring up the electronics
Writing the Python program
Breaking down the program
Summary
Scrolling LED Badge
What we will cover
The bill of parts
Putting the hardware together
Wiring up the Scroll pHAT HD
Wiring up the Pi
Attaching the Pi and the Scroll pHAT HD
Installing and writing the software
Testing our Scoll pHAT HD
Our scrolling badge program
Making our program start automatically
Creating our systemd service definition
Finalizing our hardware setup
Wiring an off switch to our Pi Zero
Write our shutdown program
Making our shutdown program run automatically
Putting it all together
Installing the Pi Zero into its case
Making our Scroll pHAT HD badge
Summary
Sewable LEDs in Clothing
What We Will Cover
The bill of parts
Modifying our item of clothing
Our hidden pocket
Adding our sewable LEDs
Connecting our Pi Zero
Writing our Python program
Testing our LEDs
Our final LED program
Making our program start automatically
Summary
A Motion-Reactive LED Cap
What we will cover
The bill of parts
Connecting our hardware
Connecting our accelerometer
Testing our accelerometer
Connecting our Blinkt
Testing Blinkt
Modifying our cap
Writing our program
Understanding our accelerometer readings
What did we just do?
Making our program start automatically
Summary
A Tweet-Activated LED T-Shirt
What we will cover
The bill of parts
Creating our personal t-shirt design
Adding our LEDs to our fabric
Testing our LEDs
Writing our main Python program
Preparing your Twitter account
Installing the Python libraries
Our first Python Tweet
Our final program
Connecting our Pi Zero to the internet
Making our program start automatically
Finalizing the garment modifications
Summary
An LED Laptop Bag
What we will cover
The bill of parts
Creating our electrical circuit
Controlling our LED strip with Python
Adding our LED strip to the bag
Writing our main Python program
Making our program start automatically
Summary
Creating Your Own Pedometer
What we will cover
The bill of parts
How a pedometer works
Setting up our hardware
Counting steps with Python
Graphing our steps
Creating our main program
Making our program run automatically
Summary
Creating Your Own Heart Rate Monitor
What we will cover
The bill of parts
Setting up our hardware
Reading our heart rate
Making our program run automatically
Summary
Creating Your Own GPS Tracker
What we will cover
The bill of parts
Setting up our hardware
Configuring our Pi Zero to connect to the hardware
Reading our GPS data
Creating KML files
Uploading KML files to Google Maps and Earth
Uploading KML files to Google Maps
Uploading KML files to Google Earth
Creating our final program
Making our program run automatically
Testing our GPS tracker
Summary
Are you interested in wearable-tech and gadgets? Do you want to know more about how you can use the Raspberry Pi Zero computer? This book has a series of projects which will show you some of the possibilities with wearable-tech and the Pi Zero, guiding you through each one from start to finish.
The Raspberry Pi Zero is a revolutionary product, designed and manufactured in the United Kingdom by the Raspberry Pi Foundation. This tiny computer provides powerful features, in spite of being such a small size; it measures a mere 65 x 35 mm! One of the advantages of its tiny size is that it is ideal to be used in wearable-tech projects.
You will begin at the beginning (as all good journeys do!) and learn how to install the required software for your upcoming projects. You will also learn how to control electronic devices with the GPIOZero Python library. Next, you will be creating some stylish wearable-tech projects such as a motion-reactive LED cap and Tweet-activated LED T-shirt. Towards the end of the book, you will be creating some useful health and fitness wearable-tech projects; these will help you monitor your heart-rate, track your movements with GPS, and count your footsteps with your own pedometer.By the end of the book, you will have created a range of wearable-tech projects and learned enough about your Raspberry Pi Zero that you should be able to adapt these projects further or come up with your own creations!
Chapter 1, About the Raspberry Pi. This chapter introduces the Raspberry Pi Zero computer that we will be using throughout the book; it explains how to get the required software installed and running. We will look at how we can connect to our Pi Zero over SSH from a remote computer so we can program it without having to attach a monitor, keyboard or mouse. We will then look at how we can control basic electronic devices using the Python GPIOZero library. Finally, we will wire up an 'off switch' to our Pi Zero, so that when it is running headless in our later projects, we can safely power it 'off'.
Chapter 2, Scrolling LED Badge. In this chapter we will make a scrolling LED badge that you can program to display any message across and can be worn while out and about. We will make use of the Scroll pHAT HD from Pimoroni and our Pi Zero to create your badge. We will also look at how we can incorporate a battery pack to make this a portable solution. We will use Python to program our Scroll pHAT HD to display whatever message we want. Finally, we will look at ensuring this program runs as soon as we turn on our Pi Zero.
Chapter 3, Sewable LEDs in Clothing. This chapter uses stitchable LEDs and conductive thread to transform an item of clothing into a sparkling LED piece of wearable-tech, controlled with a Pi Zero hidden in the item of clothing. We will incorporate a Pi Zero and battery into a hidden pocket in the garment and connect our stitchable LEDs to the Pis GPIO pins so that we can write a Python program to control the order and timings of the LEDs.
Chapter 4, A Motion-Reactive LED Cap. In this chapter we will make use of a Pimoroni Blinkt LED strip, an Adafruit Triple-Axis Accelerometer and a Pi Zero to create a cap with a super-bright strip of RGB LEDs across the front. This will change its colors and display pattern, based upon the direction and speed that the wearer moves.
Chapter 5, A Tweet activated LED T-shirt. This project shows us how to incorporate some LEDs into another item of clothing, a t-shirt or jumper, and again wire them back to a hidden Pi Zero and battery pack. With our Pi Zero connected to a Wi-Fi network, we will then write a program, which monitors Twitter and listens out for trigger phrases. Whenever these trigger phrases are detected, our LEDs will light up in the different patterns we have programmed them to.
Chapter 6, An LED Laptop bag. Here we will cut and resolder an Adafruit DotStar Strip into a matrix of super-bright, controllable RGB LEDs. We will then attach this matrix to the front of a laptop bag. Next, we will hide our Pi Zero and battery pack inside the pocket of the bag and write the Python program to control our RGB LED matrix.
Chapter 7, Create Your Own pedometer. In this chapter we will make use of an Adafruit Triple-Axis Accelerometer, a Pimoroni Scroll pHAT HD, and a Pi Zero to create our own pedometer. Once we have connected the accelerometer and Scroll pHAT HD to the Pi Zero, we will write the program, which reads the data from the accelerometer and converts it into steps taken. We will then complete our program to make it display the updating step count on the Scroll pHAT HD.
Chapter 8, Create Your Own Heart Rate Monitor. With this project, we will use a Pulse Sensor Amped to create our own heart rate monitor device. We will add a Pimoroni Enviro pHAT and a Scroll pHAT HD to enable us to read the sensor data and display an animation of a heart beating in time with ours. As well as this, the device will display our heart's current BPM on the Scroll pHAT HD.
Chapter 9, Create Your Own GPS Tracker. Our final chapter will see us create a portable GPS tracker for bikers, runners or walkers to use when out and about. The GPS tracker will log your GPS coordinates, including elevation and time. We will also configure the Pi to create a file in the correct format for you to import into Google Maps or Google Earth to plot the course you have taken.
The required hardware for each project is mentioned right at the beginning of every chapter; all software that is used in these projects is Open Source and freely available from the Internet. You will need a Raspberry Pi Zero of course; the latest Pi Zero W is recommended, so that you can make use of the on-board Wi-Fi to access your computer remotely without the need for an additional USB Wi-Fi dongle.
You will also need access to various tools for the different projects in this book. Again, each chapter details what you will need; the essential 'shopping list' includes a soldering iron, wire strippers, and a set of crocodile-clip helping hands.
Everyone.
While some prior knowledge of Python programming and use of the terminal on the Raspberry Pi would be advantageous, they are by no means necessary. Each chapter clearly sets the steps to be taken on your wearable-tech adventure. Chapter 1, About the Raspberry Pi, assumes no prior knowledge to get your Pi Zero and you up and running. The complexity of the electronic devices used progress incrementally as you work through the chapters; there are clear steps to follow and pictures to help you at every turn along the way.
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/Wearable-Tech-Projects-with-the-Raspberry-Pi-Zero. 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 with 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/WearableTechProjectswiththeRaspberryPiZero_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 the Errata 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.
Throughout this book, we will be making use of the Raspberry Pi Zero computer to create our wearable-tech projects. However, before we jump straight into our first project, we should first some time getting to know the Raspberry Pi Zero computer and performing a few basic tasks, which will be useful across all of our projects. We will first look at the history of this tiny computer, and then learn how to get our software up and running, along with connecting to the GPIO headers on our computer. We will then spend some time looking at the different ways we can access our computer when it is not connected to a keyboard, mouse, or monitor and also perform some basic electronics experiments to get to know how we can use the GPIO pins in our upcoming projects.
So, let's get started!
In this chapter, we will cover the following topics:
The history of the Raspberry Pi Zero
The parts we will need to complete this chapter
Installing our operating system onto our Pi Zero
Different ways of connecting to our GPIO headers on our PI Zero
Accessing our Pi Zero in headless mode
Creating a very basic electronics project to familiarize ourselves with using GPIO pins on our Pi
Raspberry Pi Foundation launched the Raspberry Pi Zero on 26th November 2015, taking the IT world by surprise by releasing it secretly at a price of just $5, along with including a free Raspberry Pi Zero for those who were lucky enough to get a copy of that month's MagPie magazine. Needless to say, these tiny computers sold out quickly and, to this day, customers are still limited to purchasing just one device per order from the suppliers who stock them.
In April 2016, a new version of the Pi Zero was launched; a camera port was added to this model, enabling enthusiasts to build super small camera projects and hacks using their Raspberry Pi Zero computers.
The newest and latest version of Raspberry Pi Zero is Pi Zero W. It adds to the second generation of Pi Zero by now including the same Wi-Fi and Bluetooth on-board chip, which was introduced on Pi 3. This makes Pi Zero W a great choice of computer for our projects in this book; it has enough power to deliver what we want, and GPIO pins allow us to connect to and control all manner of devices (as we will see!); and we now have a means to connect to this computer, while it is hidden away in a piece of clothing!
