Make: Getting Started with the Photon
by Simon Monk
Copyright 2015 Maker Media. All rights reserved.
Printed in the United States of America.
Published by Maker Media, Inc. , 1160 Battery Street East, Suite 125, San Francisco, CA 94111.
Maker Media books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Editor: Roger Stewart
- Production Editor: Kristen Brown
- Proofreader: Sharon Wilkey
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Rebecca Demarest
- Technical Reviewers: Dr. Stephen Hall and Brett Walach
Revision History for the First Edition
- 2015-04-24: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781457187018 for release details.
The Make logo and Maker Media logo are registered trademarks of Maker Media, Inc. Make: Getting Started with the Photon, the cover image, and related trade dress are trademarks of Maker Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-457-18701-8
[LSI]
Foreword
According to MIT Technology Review, 2013 was the year of the Internet of Things. The following year, Cisco said 2014 was the year of the Internet of Things. This year, CNBC says that 2015 is the year of the Internet of Things. It is likely that every year for the next decade will be the year of the Internet of Things. But what does that mean, exactly?
The Internet of Things (IoT) is a broad concept that suggests that as the cost of connectivity comes down, more and more objects around us will be Internet-connected. Were used to thinking about the Internet in terms of devices with screens: your personal computer, for instance, and your smartphone. The Internet of Things covers devices that you wouldnt typically think about being connected to the Internet, and includes categories like wearables (Fitbit, smart watches), smart home (connected lights, appliances, and toys), the industrial Internet (feedback systems on wind turbines), smart cities (connected parking meters and traffic lights), smart farms (connected irrigation systems), and more. Its a category that is difficult to define because of its breadth, but the common thread is that things that werent connected before are becoming connected now.
I believe that the Internet of Things is the third wave of personal computing (the first being the PC, and the second being smartphones). And, unlike the tech press, I dont think weve reached the year of the Internet of Things quite yet. I believe were still in the prototyping days, where even most IoT products coming to market are just the first experiments that will give way to a large, vibrant ecosystem in a few years time. This is like the early 90s for the Internet, or the early 2000s for smartphones.
And, like PCs and smartphones, the rapid growth that were seeing nowand that well continue to see for the next decadewill present massive opportunities for the people who jump in early. Industries will change, jobs will be created, and fortunes will be made and lost.
This book is about a tool: the Photon. The Photon is a simple development kit, but it represents a starting point that can take you much further. Your journey may start with the Photon and end with a connected garage-door opener for your house. Or it may end with a connected garage-door opener that you bring to market and sell to hundreds of thousands of people around the world.
For you, dear reader, the year of the Internet of Things will be the year that you join in. Every great company starts as an idea, and every great product starts as a prototype. What will you build first?
Zach Supalla, Founder and CEO of Particle, April 2015
Preface
Whats in a Name?
This book has been written at a time when the Spark organization was rebranding itself as Particle. As a result of this, you will find that some of the screenshots have the old company name, as they were taken before the new web interface became available. You will also find that the code for this book uses class names and third-party code libraries that still show the Spark name. These are set to work in the short term, but when they eventually become deprecated, watch for information on these changes at the Particle website.
Conventions Used in This Book
The following typographical conventions are used in this book:
ItalicIndicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
Note
This element signifies a general note, tip, or suggestion.
Warning
This element indicates a warning or caution.
Using Code Examples
The code examples are all available as a code library directly from the Web IDE. They are also available for download at https://github.com/simonmonk/photon_book.
This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless youre reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from Make: books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your products documentation does require permission.
If you feel your use of code examples falls outside fair use or the permission given here, feel free to contact us at .
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: Make: Getting Started with the Photon by Simon Monk (Maker Media). Copyright 2015 Maker Media, 978-1-4571-8701-8.
Safari Books Online
Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the worlds leading authors in technology and business.
Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.