Table of Contents
Foreword vii
Preface ix
1 The Photon 1
The Internet of Things 1
Sparks in the Clouds 2
Other IoT Platforms 3
Arduino 4
Raspberry Pi and BeagleBone 6
Intel Edison 6
A Tour of the Photon 7
The Spark Core vs. Photon 9
Programming 10
Summary 11
2 Quick Start 13
Signing Up 13
Connecting to WiFi 13
Connecting a Core 14
Connecting a Photon 17
Controlling Pins with the Tinker App 24
Project 1 Blink the Tiny Blue LED 24
Project 2 Control the Photon's LED 27
Summary 29
3 Programming the Photon 31
The Web IDE 31
Coding an App 33
Comments 37
Variables 38
Morse Code 39
Flashing SOS 40
Functions 44
Types 46
The int Type 48
The float Type 48
Other Types 49
Arrays 49
Loops 51
Strings 53
Ifs 54
Project 3 Morse Code Flasher 55
Software 55
Summary 58
4 Breadboard 59
How a Breadboard Works 61
Attaching an LED 62
Digital Outputs 63
Project 4 Morse Flasher (External LED) 64
Parts 64
Hardware 64
Software 66
Attaching a Switch 67
Digital Inputs 68
Project 5 Morse Flasher with Switch 69
Parts 69
Software 70
Hardware 71
Running the Project 72
Analog Outputs 73
Analog Write 74
An Example 74
A Real Analog Output 76
Summary 77
5 The Internet of Things 79
Functions 79
Project 6 Control an LED over the Internet 81
Software 82
Security 83
Trying It Out 85
Interacting with loop 86
Running Functions from a Web Page 88
Project 7 Control Relays from a Web Page 91
Parts 93
Design 95
Construction 95
Software 97
Project 8 Morse Code Text Messages 103
Parts 104
Software 104
Hardware 108
Using the Project 109
Variables 109
Analog Inputs 110
Project 9 Measuring Light over the Internet 114
Parts 114
Software 115
Hardware 117
Using the Project 120
Project 10 Measuring Temperature over the Internet 120
Parts 121
Software 122
Hardware 124
Using the Project 125
Summary 127
6 If This Then That 129
If This Then That 129
Project 11 Temperature Email Alerts 129
Project 12 Ring a Bell for Tweets 137
Software 138
IFTTT 139
Hardware 140
Using the Project 141
Project 13 Flash Email as Morse Code 141
Software 142
Hardware 142
IFTTT 142
Using the Project 143
Summary 143
7 Robotics 145
Project 14 Web-Controlled Robot 145
Parts 147
Software (Photon) 147
Software (Web Page) 150
Hardware 152
Using the Project 154
Summary 155
8 Machine-to-Machine Communication 157
Publish and Subscribe 157
Temperature Monitor Example 158
IFTTT and Publish/Subscribe 162
Advanced Publish and Subscribe 163
Publish 163
Subscribe 163
Project 15 Magic Rope 164
Parts 166
Software 167
Hardware 169
Using the Project 173
Summary 173
9 Advanced Photon 175
Configuring a Photon Using USB 175
Factory Reset 178
Programming a Photon Using Particle Dev 179
Debugging with the Serial Monitor 179
The Electron 180
Power Management 181
Summary 181
A Parts 183
B Photon LED Codes 187
C Photon and Core Pinouts 189