O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mastering Internet of Things

Book Description

Augment your IoT skills with the help of engaging and enlightening tutorials designed for Raspberry Pi 3

About This Book

  • Design and implement state-of-the-art solutions for the Internet of Things
  • Build complex projects using motions detectors, controllers, sensors, and Raspberry Pi 3
  • A hands-on guide that provides interoperable solutions for sensors, actuators, and controllers

Who This Book Is For

If you're a developer or electronic engineer and are curious about the Internet of Things, this is the book for you. With only a rudimentary understanding of electronics and Raspberry Pi 3, and some programming experience using managed code, such as C# or Java, you will be taught to develop state-of-the-art solutions for the Internet of Things.

What You Will Learn

  • Create your own project, run and debug it
  • Master different communication patterns using the MQTT, HTTP, CoAP, LWM2M and XMPP protocols
  • Build trust-based as hoc networks for open, secure and interoperable communication
  • Explore the IoT Service Platform
  • Manage the entire product life cycle of devices
  • Understand and set up the security and privacy features required for your system
  • Master interoperability, and how it is solved in the realms of HTTP,CoAP, LWM2M and XMPP

In Detail

The Internet of Things (IoT) is the fastest growing technology market. Industries are embracing IoT technologies to improve operational expenses, product life, and people's well-being. Mastering Internet of Things starts by presenting IoT fundamentals and the smart city. You will learn the important technologies and protocols that are used for the Internet of Things, their features, corresponding security implications, and practical examples on how to use them. This book focuses on creating applications and services for the Internet of Things. Further, you will learn to create applications and services for the Internet of Things. You will be discover various interesting projects and understand how to publish sensor data, control devices, and react to asynchronous events using the XMPP protocol. The book also introduces chat, to interact with your devices. You will learn how to automate your tasks by using Internet of Things Service Platforms as the base for an application. You will understand the subject of privacy, requirements they should be familiar with, and how to avoid violating any of the important new regulations being introduced.

At the end of the book, you will have mastered creating open, interoperable and secure networks of things, protecting the privacy and integrity of your users and their information.

Style and approach

This mastering-level guide will immerse you in the advanced functionalities of IoT, along with extending them, and finishes up with security and privacy techniques.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased 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.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering Internet of Things
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Defining the Internet of Things
    2. Competing terminology
    3. Envisioning the Smart City
    4. What this book covers
    5. What you need for this book
    6. Who this book is for
      1. Conventions
    7. Reader feedback
    8. Customer support
      1. Downloading the color images of this book 
      2. Download the example code files
      3. Errata
      4. Piracy
      5. Questions
  7. Preparing Our First Raspberry Pi Project
    1. Getting what you need
      1. Downloading the IoT Dashboard
      2. Installing Windows 10 on your Raspberry Pi
    2. Starting your Raspberry Pi
      1. Connecting to your Raspberry Pi
      2. Downloading the Arduino IDE
        1. Installing Firmata on your Arduino board
      3. Testing your Arduino board
      4. Choosing a development environment
      5. Using the IoT Gateway project and libraries
    3. Creating your first project
      1. Adding NuGet packages
      2. Aggregating capabilities
      3. Initializing the application
      4. Communicating with the Arduino
      5. Testing the app
      6. Deploying the app
    4. Summary
  8. Creating a Sensor to Measure Ambient Light
    1. Preparing our project
      1. Initializing the inventory library
      2. Initializing the persistence library
    2. Sampling raw sensor data
    3. Performing basic error correction
      1. Canceling noise
      2. Removing random spikes
    4. Converting to a physical quantity
    5. Illustrating measurement results
    6. Calculating basic statistics
    7. Defining data persistence
    8. Storing measured data
    9. Removing old data
    10. Summary
  9. Creating an Actuator for Controlling Illumination
    1. Preparing our project
    2. Defining control parameters
    3. Understanding relays
    4. Connecting our lamp
    5. Connecting an LED
    6. Controlling output
      1. Persisting control parameter states
      2. Logging important control events
    7. Using Raspberry Pi GPIO pins directly
      1. Checking whether GPIO is available
      2. Initializing the GPIO output pin
      3. Setting the GPIO pin output
    8. Summary
  10. Publishing Information Using MQTT
    1. Introducing the MQTT protocol
      1. Understanding the Publish/Subscribe pattern
    2. Preparing our project
      1. Selecting an MQTT broker
      2. Creating a Device ID
      3. Connecting to the broker
      4. Monitoring connection events
      5. Recovering from lost connections
    3. Publishing sensor data
      1. Choosing relevant values
      2. Choosing a quality of service
      3. Publishing the light field
    4. Checking encrypted communication
    5. Adding MQTT support to the actuator
      1. Subscribing to topics
      2. Handling incoming commands
    6. Testing MQTT
    7. Security considerations
      1. Managing authentication
      2. Managing privacy
      3. Managing interoperability
      4. Managing authorization
    8. Summary
  11. Publishing Data Using HTTP
    1. Introducing the HTTP protocol
      1. Locating a resource
      2. Understanding the Request/Response pattern
      3. Handling sessions
      4. Limiting connectivity
      5. Choosing a connection direction
      6. Understanding methods
      7. Updating resources
      8. Interacting with resources
      9. Encoding content
      10. Applying headers
      11. Optimizing requests
      12. Sending content
      13. Understanding status codes
      14. Using encryption
      15. Validating certificates
      16. Redefining the web
    2. Preparing our project
      1. Creating an HTTP server
    3. Adding dynamic synchronous resources
      1. Choosing representation
      2. Returning an XMLresponse
      3. Adding a schema reference
      4. Adding momentary values
      5. Returning an image response
      6. Explicitly encoding your content
    4. Adding dynamic asynchronous resources
      1. Decoding content
      2. Performing control action
    5. Summary
  12. Creating Web Pages for Your Devices
    1. Adding file-based resources to your projects
      1. Converting Markdown to HTML in real time
      2. Adding simple Markdown content to the sensor project
      3. Calling our sensor API from JavaScript
      4. Adding simple Markdown content to the actuator project
      5. Calling our actuator API from JavaScript
      6. Adding default redirections
    2. Plotting graphs
      1. Reading historical values from the database
      2. Plotting historical values
      3. Displaying the plot
      4. Generalizing the page
    3. Creating a menu system
      1. Creating the master document
      2. Referencing the menu
    4. Authenticating users
      1. Adding a login page
      2. Creating our user
      3. Creating a very simple user database
      4. Posting login form
      5. Parsing the form
      6. Redirecting the user
      7. Authenticating the user
    5. Protecting our web services
      1. Getting a session token
      2. Validating tokens
      3. Using tokens in JavaScript
    6. Summary
  13. Communicating More Efficiently Using CoAP
    1. Introducing CoAP
      1. Using UDP
      2. Efficiently distributing data
      3. Understanding the Observe pattern
      4. Securing CoAP communication
      5. Understanding DTLS sessions
      6. Encoding content
    2. Adding CoAP to our devices
      1. Creating a CoAP endpoint
      2. Publishing interval-based observable data
      3. Publishing event-based observable data
      4. Choosing the desired representation
      5. Returning CoAP content
      6. Adding a control resource to our actuator
      7. Responding to change requests
      8. Adding output triggers
    3. Testing your devices
      1. Discovering the contents of your device
      2. Controlling your device
    4. Securing your devices
      1. Limitations of CoAP
    5. Summary
  14. Interoperability
    1. Understanding the benefits of interoperability
      1. The benefits of application-layer standards
      2. Understanding coupling
    2. Achieving interoperability using CoAP
      1. Discovering resources using CoRE
      2. Understanding the LWM2M object model
      3. Understanding the LWM2M infrastructure
      4. Understanding LWM2M server operations
      5. Using IPSO Smart Objects
    3. Adding LWM2M to our devices
      1. Creating an LWM2M client
      2. Performing the bootstrap procedure
      3. Registering with the LWM2M servers
      4. Following the progress
      5. Defining Smart Objects
        1. Creating the digital input object class
        2. Creating the digital input object instance class
        3. Defining trigger intervals for observable resources
        4. Notifying subscribers manually
        5. Instantiating the digital input object
        6. Creating the digital output object instance class
        7. Setting remotely updated output values
    4. Testing your LWM2M device
      1. Configuring the bootstrap server
      2. Configuring the LWM2M server
      3. Interacting with your devices
    5. Summary
  15. Social Interaction with Your Devices Using XMPP
    1. Introducing XMPP
      1. Using XML
      2. Understanding the value of brokers
        1. Providing global scalability
        2. Extending server functionality
        3. Authenticating clients
      3. Understanding XMPP addresses
      4. Using trust-based communication to secure the network
      5. Understanding XMPP communication patterns
      6. Understanding stanzas
      7. Extending XMPP
      8. Selecting a client library
      9. Selecting a broker
    2. Adding XMPP to our devices
      1. Connecting to our broker
        1. Getting persisted credentials
        2. Preparing the connection for first-time use
        3. Connecting to the server
        4. Following the connection process
        5. Registering a new account
        6. Maintaining the connection
        7. Managing the roster
      2. Making sensor data available over XMPP
        1. Understanding the conceptual model
        2. Creating an XMPP sensor server
        3. Returning momentary values
        4. Returning historical values
        5. Returning writable values
        6. Triggering events
      3. Publishing control parameters
        1. Understanding the conceptual model
        2. Creating an XMPP control server
      4. Adding a chat interface
        1. Creating an XMPP chat server
      5. Testing your devices
        1. Testing the human interface
        2. Testing the machine interface
      6. For further study
    3. Summary
  16. The Controller
    1. Discovering things on the internet
      1. Introducing Thing Registry
      2. Propagating information
      3. Claiming ownership of things
      4. Transferring the conceptual identity to the owner
      5. Using thing registries in XMPP
    2. Registering our devices
      1. Looping through available components
      2. Finding the thing registry
      3. Creating a Thing Registry client
      4. Defining the conceptual identity of the thing
      5. Adding existing location information
      6. Collecting location information
      7. Registering the device
      8. Updating a registration
    3. Creating a controller
      1. Identifying things
      2. Finding friends in the roster
      3. Limiting the search domain
      4. Performing the search
      5. Picking suitable devices
      6. Making new friends
      7. Reacting to roster events
      8. Adding a friend
      9. Losing a friend
      10. Reacting to revoked presence subscriptions
      11. Reacting to presence changes
      12. Interacting with devices
      13. Subscribing to sensor data events
      14. Reacting to sensor data events
      15. Collecting relevant sensor data
      16. Calculating control output
      17. Performing control action
      18. Recovering from stale states
      19. Re-subscribing to sensor data
      20. Invalidating existing friendships
      21. Reconfiguring the controller
      22. Decommissioning of devices
    4. Summary
  17. Product Life Cycle
    1. Defining ownership of data
      1. Choosing who should own the data
      2. Understanding ownership of physical objects
      3. Defining ownership of information
    2. Understanding provisioning
      1. Using a Thing Registry to register ownership
      2. Provisioning of a claimed thing
      3. Ending ownership
    3. Adding provisioning support to our devices
      1. Searching for a provisioning server
      2. Creating a provisioning client
      3. Adding provisioning support
      4. Registration of device
      5. Transmitting the conceptual identity
      6. Reacting to claims
      7. Updating the registration of our device
      8. Reacting to being disowned
    4. Managing the owner side
      1. Deciding what to do
      2. Managing owned devices
    5. Using tokens for identification
    6. Testing provisioning
      1. Provisioning your devices
      2. Claiming a device
      3. Adding rules
    7. Summary
  18. Concentrators and Bridges
    1. Introducing concentrators
      1. Understanding concentrators in XMPP
      2. Modeling a Programmable Logic Controller
      3. Bridging protocols
      4. Integrating backend systems
    2. Referencing embedded nodes
      1. Referencing embedded sensor nodes
      2. Supporting embedded sensor nodes
      3. Referencing embedded actuator nodes
      4. Supporting embedded actuator nodes
      5. Using embedded nodes in Thing Registries
      6. Using embedded nodes in provisioning
    3. Managing a concentrator
      1. Interfacing a concentrator
      2. Building a concentrator
      3. Defining data sources
      4. Defining embedded nodes
      5. Redirecting node requests
    4. Implementing a concentrator
      1. Instantiating the concentrator
      2. Defining the data source
      3. Providing basic access control
      4. Publishing our nodes
      5. Defining our embedded sensor node
        1. Defining basic properties
        2. Defining the node topology
        3. Providing displayable parameters
        4. Providing status feedback
        5. Performing readout of a sensor
      6. Defining our embedded actuator node
        1. Defining control parameters for embedded nodes
      7. Registering our embedded nodes
      8. Trying your concentrator
    5. Adding provisioning support to the concentrator
    6. Summary
  19. Using an Internet of Things Service Platform
    1. Understanding the IoT Gateway project
    2. Running the IoT Gateway
      1. Running the console version
      2. Running the gateway as a Windows service
      3. Running the gateway as an app
    3. Configuring the IoT Gateway
      1. Configuring the XMPP interface
      2. Securing the password
      3. Setting basic properties of the gateway
      4. Providing a certificate
    4. Providing web content
      1. Publishing network folders
      2. Using Markdown
      3. Using metadata for Search Engine Optimization
      4. Providing menus using the Master/Detail model
      5. Customizing the user experience
      6. Adding security headers
      7. Authorizing user privileges
      8. Customizing content using server-side script
        1. Using pre-processed script
        2. Interacting with .NET code from script
        3. Testing script
      9. Customizing code visualization
        1. Visualizing Graphviz graphs
      10. Customizing multimedia presentation
      11. Pushing information to web clients
    5. Monitoring performance
      1. Monitoring event logs
      2. Monitoring communication sniffers
    6. Developing services for the IoT Gateway
      1. Creating a service module
      2. Understanding the basic architecture
      3. Creating a manifest file
      4. Installing your service
      5. Testing and debugging your service
      6. Deploying your service to an embedded device
      7. Extending communication capabilities
      8. Interfacing things
        1. Using the Metering Topology data source
        2. Controlling node hierarchy
        3. Editing node properties
        4. Interacting with your things
        5. Managing your things
      9. Packaging your service
        1. Creating an installer
    7. Summary
  20. IoT Harmonization
    1. Envisioning the Smart City
      1. Deriving some immediate consequences
      2. Avoiding the lure of the dark side
      3. Understanding the driving forces
      4. Dividing responsibilities
    2. Proposing a solution
      1. Developing standards
      2. Using abstractions
      3. Choosing XMPP
      4. Defining economic feedback models
      5. Defining new roles
    3. Summary
  21. Security for the Internet of Things
    1. Understanding the risks
    2. Getting to a bad place
    3. Understanding the root causes
    4. Looking at alternative options
    5. Getting to a better place
    6. Mastering data protection technologies
      1. Skimming the basics of encryption
      2. Protecting data integrity
      3. Understanding key sizes
      4. Using certificates
      5. Avoiding self-signed certificates
      6. Avoiding creating a Certificate Authority
      7. Using tokens to transport claims
      8. Enforcing ubiquitous encryption
      9. Creating checklists
      10. Updating your firmware
      11. Distributing your risks
      12. Avoiding leaking data unintentionally
    7. Summary
  22. Privacy
    1. Defining privacy
      1. Understanding the importance
      2. Understanding what it means
      3. Being informed
    2. Introducing the GDPR
      1. Balancing rights
      2. Measuring proportionality
      3. Defining personal data
      4. Anonymizing data
      5. Defining processing
      6. Doing as little as possible
      7. Informing the data subjects
      8. Finding your legal grounds
      9. Avoiding certain topics
      10. Distributing responsibilities
      11. Avoiding sanctions
      12. Assisting controllers and processors
      13. Protecting personal data
      14. Giving individual rights
    3. Solving the puzzle
    4. Summary
  23. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think