Building the Web of Things
With examples in Node.js and Raspberry Pi
Dominique D. Guinard and Vlad M. Trifa
  • June 2016
  • ISBN 9781617292682
  • 344 pages
  • printed in black & white

A fantastic set of ideas and a great addition to the IoT toolkit.

Mike Kuniavsky, Innovation Services at PARC

A hands-on guide that teaches you how to design and implement scalable, flexible, and open IoT solutions using web technologies. This book focuses on providing the right balance of theory, code samples, and practical examples to enable you to successfully connect all sorts of devices to the web and to expose their services and data over REST APIs.

Table of Contents detailed table of contents

Part 1

1. From the Internet of Things to the Web of Things

1.1. Defining the Internet of Things

1.2. Enter the Web of Things

1.2.1. Web of Things scenario: connected hotel

1.2.2. Comparing IoT and WoT

1.2.3. The Internet of Things—a brief history

1.3. Use cases—why connected objects?

1.3.1. Wireless sensor networks and distributed sensing

1.3.2. Wearables and quantified self

1.3.3. Smart homes and buildings

1.3.4. Smart cities and energy grids

1.3.5. Smart manufacturing and Industry 4.0

1.3.6. Smart logistics and supply chains

1.3.7. Marketing 2.0

1.4. The Web of Things—a supercharged Internet of Things

1.4.1. Easier to program

1.4.2. Open and extensible standards

1.4.3. Fast and easy to deploy, maintain, and integrate

1.4.4. Loose coupling between elements

1.4.5. Widely used security and privacy mechanisms

1.4.6. WoT—the shortcomings

1.5. Summary

2. Hello, World Wide Web of Things

2.1. Meet a Web of Things device

2.1.1. The suspect: Raspberry Pi

2.2. Exercise 1—Browse a device on the Web of Things

2.2.1. Part 1—The web as user interface

2.2.2. Part 2—The web as an API

2.2.3. So what?

2.3. Exercise 2—Polling data from a WoT sensor

2.3.1. Part 1—Polling the current sensor value

2.3.2. Part 2—Polling and graphing sensor values

2.3.3. Part 3—Real-time data updates

2.3.4. So what?

2.4. Exercise 3—Act on the real world

2.4.1. Part 1—Use a form to update text to display

2.4.2. Part 2—Create your own form to control devices

2.4.3. So what?

2.5. Exercise 4—Tell the world about your device

2.5.1. So what?

2.6. Exercise 5—Create your first physical mashup

2.6.1. So what?

2.7. Summary

3. Node.js for the Web of Things

3.1. The rise of JavaScript: from clients to servers to things!

3.1.1. Pushing JavaScript to things

3.2. Introduction to Node.js

3.2.1. Installing Node.js on your machine

3.2.2. Your first web server in Node.js

3.2.3. Returning sensor data as JSON

3.3. Modularity in Node.js

3.3.1. npm—the Node package manager

3.3.2. Clean dependencies with package.json and npm

3.3.3. Your first Node module

3.4. Understanding the Node.js event loop

3.4.1. Multithreaded web servers

3.4.2. Single-threaded, non-blocking web servers

3.5. Getting started with asynchronous programming

3.5.1. Anonymous callbacks

3.5.2. Named callbacks

3.5.3. Control flow libraries

3.6. Summary and beyond the book

4. Getting started with embedded systems

4.1. The world of embedded devices

4.1.1. Devices for hobbyists vs. industrial devices

4.1.2. Real-time operating systems vs. Linux

4.1.3. Summary and beyond the Pi

4.2. Set up your first WoT device—Raspberry Pi

4.2.1. Meet the Raspberry Pi

4.2.2. Choosing your Pi

4.2.3. Shopping list

4.2.4. Setting up your Raspberry Pi

4.2.5. Connecting to your device

4.3. Installing Node.js on the Raspberry Pi

4.3.1. Using Git and GitHub on the Pi

4.3.2. So what?

4.4. Connecting sensors and actuators to your Pi

4.4.1. Understanding GPIO ports

4.4.2. Working with breadboards and electronic components

4.4.3. Accessing GPIOs from Node.js

4.4.4. Beyond the book

4.5. Summary

5. Building networks of Things

5.1. Connecting Things

5.1.1. Network topologies

5.1.2. Network classification models

5.2. Networking protocols for Things

5.2.1. Spatial considerations

5.2.2. Internet protocols and the IoT

5.2.3. IoT personal area networks

5.2.4. IoT wide area networks

5.2.5. So, which one should I choose?

5.3. Application protocols for Things

5.3.1. ZigBee and Bluetooth application stacks

5.3.2. Apple HomeKit and Google Weave

5.3.3. Message Queuing Telemetry Transport

5.3.4. Constrained Application Protocol

5.3.5. So, which one should I use?

5.4. The Web of Things architecture

5.4.1. Layer 1: Access

5.4.2. Layer 2: Find

5.4.3. Layer 3: Share

5.4.4. Layer 4: Compose

5.4.5. Why does the WoT matter?

5.4.6. Beyond the book

5.5. Summary

Part 2

6. Access: web APIs for Things

6.1. Devices, resources, and web Things

6.1.1. Representational State Transfer

6.1.2. Why do we need a uniform interface?

6.1.3. Principle 1: addressable resources

6.1.4. Principle 2: manipulation of resources through representations

6.1.5. Principle 3: self-descriptive messages

6.1.6. Principle 4: Hypermedia as the Engine of Application State

6.1.7. Summary—web Things design process

6.2. Beyond REST: the real-time Web of Things

6.2.1. The WoT needs events!

6.2.2. Publish/subscribe

6.2.3. Webhooks—HTTP callbacks

6.2.4. Comet—hacking HTTP for a real-time web

6.2.5. WebSockets

6.2.6. The future: from HTTP/1.1 to HTTP/2

6.3. Summary

7. Implementing web Things

7.1. Connecting devices to the web

7.2. Direct integration pattern—REST on devices

7.2.1. Creating a WoT server

7.2.2. Resource design

7.2.3. Representation design

7.2.4. Interface design

7.2.5. Pub/sub interface via WebSockets

7.2.6. Summary—direct integration pattern

7.3. Gateway integration pattern—CoAP example

7.3.1. Running a CoAP server

7.3.2. Proxying CoAP via a gateway

7.3.3. Summary—gateway integration pattern

7.4. Cloud integration pattern—MQTT over EVRYTHNG

7.4.1. Set up your EVRYTHNG account

7.4.2. Create your MQTT client application

7.4.3. Use actions to control the power plug

7.4.4. Create a simple WebSockets control application

7.4.5. Summary—cloud integration pattern

7.5. Summary

8. Find: describe and discover web Things

8.1. The findability problem

8.2. Discovering Things

8.2.1. Network discovery

8.2.2. Resource discovery on the web

8.3. Describing web Things

8.3.1. Introducing the Web Thing Model

8.3.2. Metadata

8.3.3. Properties

8.3.4. Actions

8.3.5. Things

8.3.6. Implementing the Web Thing Model on the Pi

8.3.7. Summary—the Web Thing Model

8.4. The Semantic Web of Things

8.4.1. Linked data and RDFa

8.4.2. Agreed-upon semantics: Schema.org

8.4.3. JSON-LD

8.4.4. Beyond the book

8.5. Summary

9. Share: securing and sharing web Things

9.1. Securing Things

9.1.1. Encryption 101

9.1.2. Web Security with TLS: the S of HTTPS!

9.1.3. Enabling HTTPS and WSS with TLS on Your Pi

9.2. Authentication and Access Control

9.2.1. Access Control with REST & API Tokens

9.2.2. OAuth: a Web Authorization Framework

9.3. The Social Web of Things

9.3.1. A Social Web of Things Authentication Proxy

9.3.2. Implementing a Social WoT Authentication Proxy

9.4. Beyond the Book

9.5. Summary

10. Compose: physical mashups

10.1. Building a simple app—automated UI generation

10.1.1. A universal user interface for web Things

10.2. Physical mashups

10.2.1. Boxes and wires mashups for the Physical Web: Node-RED

10.3. Using wizards for physical mashups: IFTTT

10.3.1. Pushing intruder alert tweets to a Google spreadsheet

10.3.2. Sending requests to a Thing with the Maker Chanel

10.3.3. Pushing intruder alert tweets to a Google spreadsheet

10.4. Beyond the book

10.4.1. From simple mashups to big data mashups

10.4.2. A better user experience

10.5. Summary

Appendixes

Appendix A: Arduino, BeagleBone, Intel Edison, and the WoT

A.1. Integrating a BeagleBone to the WoT

A.1.1. Meet the BeagleBone Black

A.1.2. Preparing the BeagleBone Black for the book

A.2. Integrating an Intel Edison to the WoT

A.2.1. Preparing the Edison for the Book

A.3. Integrating an Arduino to the WoT

A.3.1. Linux, SSH, Node.js

A.4. Integrating other embedded systems to the WoT

About the Technology

Because the Internet of Things is still new, there is no universal application protocol. Fortunately, the IoT can take advantage of the web, where IoT protocols connect applications thanks to universal and open APIs.

About the book

Building the Web of Things is a guide to using cutting-edge web technologies to build the IoT. This step-by-step book teaches you how to use web protocols to connect real-world devices to the web, including the Semantic and Social Webs. Along the way you’ll gain vital concepts as you follow instructions for making Web of Things devices. By the end, you’ll have the practical skills you need to implement your own web-connected products and services.

What's inside

  • Introduction to IoT protocols and devices
  • Connect electronic actuators and sensors (GPIO) to a Raspberry Pi
  • Implement standard REST and Pub/Sub APIs with Node.js on embedded systems
  • Learn about IoT protocols like MQTT and CoAP and integrate them to the Web of Things
  • Use the Semantic Web (JSON-LD, RDFa, etc.) to discover and find Web Things
  • Share Things via Social Networks to create the Social Web of Things
  • Build a web-based smart home with HTTP and WebSocket
  • Compose physical mashups with EVRYTHNG, Node-RED, and IFTTT

About the reader

For both seasoned programmers and those with only basic programming skills.

About the authors

Dominique Guinard and Vlad Trifa pioneered the Web of Things and cofounded EVRYTHNG, a large-scale IoT cloud powering billions of Web Things.


Buy
combo $34.99 pBook + eBook
eBook $27.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

IoT needs an application layer, and leveraging the web is the right thing to do! This terrific book will show you how to get there in a few weeks.

Sanjay Sarma, AutoID Labs, MIT

Dom and Vlad are thought leaders in IoT, focused on how to achieve results in practice.

Andy Chew, Cisco UK

A complex subject covered in detail from beginning to end ... very readable too!

Steve Grey-Wilson, Thingworx, A PTC Business