Programming the Internet of Things

Book description

Learn how to program the Internet of Things with this hands-on guide. By breaking down IoT programming complexities in step-by-step, building-block fashion, author and educator Andy King shows you how to design and build your own full-stack, end-to-end IoT solution--from device to cloud. This practical book walks you through tooling, development environment setup, solution design, and implementation.

You'll learn how a typical IoT ecosystem works, as well as how to tackle integration challenges that crop up when implementing your own IoT solution. Whether you're an engineering student learning the basics of the IoT, a tech-savvy executive looking to better understand the nuances of IoT technology stacks, or a programmer building your own smart house solution, this practical book will help you get started.

  • Design an end-to-end solution that implements an IoT use case
  • Set up an IoT-centric development and testing environment
  • Organize your software design by creating abstractions in Python and Java
  • Use MQTT, CoAP, and other protocols to connect IoT devices and services
  • Create a custom JSON-based data format that's consumable across a range of platforms and services
  • Use cloud services to support your IoT ecosystem and provide business value for stakeholders

Publisher resources

View/Submit Errata

Table of contents

  1. Foreword
  2. Preface
    1. Who Is This Book For?
      1. To the Programmer
      2. To the Instructor
      3. To the Technology Manager or Executive
    2. What Do I Need to Know?
    3. How Is This Book Arranged?
      1. Part I, “Getting Started”
      2. Part II, “Connecting to the Physical World”
      3. Part III, “Connecting to Other Things”
      4. Part IV, “Connecting to the Cloud”
    4. Some Background on the IoT
      1. Complexity Redefined
      2. Creating Value
      3. Living on the Edge
      4. Conclusion
    5. Conventions Used in This Book
    6. Using Code Examples
    7. O’Reilly Online Learning
    8. How to Contact Us
    9. Acknowledgments
  3. I. Getting Started
  4. 1. Getting Started
    1. What You’ll Learn in This Chapter
    2. Defining Your System
      1. Breaking Down the Problem
      2. Defining Relevant Outcomes
      3. Architecting a Solution
    3. Setting Up Your Development and Test Environment
      1. Step I: Prepare Your Development Environment
      2. Step II: Define Your Testing Strategy
      3. Step III: Manage Your Design and Development Workflow
      4. Thoughts on Automation
    4. Programming Exercises
      1. Testing the Constrained Device App
      2. Testing the Gateway Device App
    5. Conclusion
  5. 2. Initial Edge Tier Applications
    1. What You’ll Learn in This Chapter
    2. Design Concepts
    3. Tracking Your Requirements
    4. Programming Exercises
      1. Add System Performance Tasks to the Constrained Device Application
      2. Add System Performance Tasks to the Gateway Device Application
    5. Additional Exercises
    6. Conclusion
  6. II. Connecting to the Physical World
  7. 3. Data Simulation
    1. What You’ll Learn in This Chapter
    2. Simulating Sensors and Actuators
      1. Generating Simulated Data Using a Sensor Data Generator Class
    3. Programming Exercises
      1. Integrating Sensing and Actuation Simulation Within Your Application Design
      2. Representing Sensor and Actuator Data Within the Application
      3. Create Data Containers to Support Data Collection and Actuation
      4. Simulating Sensors
      5. Simulating Actuators
      6. Connecting Simulated Sensors with the Sensor Adapter Manager
      7. Connecting Simulated Actuators with the Actuator Adapter Manager
      8. Create and Integrate the Device Data Manager
    4. Additional Exercises
      1. Hysteresis Management
    5. Conclusion
  8. 4. Data Emulation
    1. What You’ll Learn in This Chapter
    2. Emulating Sensors and Actuators
      1. Setting Up and Configuring an Emulator
      2. The Sense-Emu Sense HAT Emulator
    3. Programming Exercises
      1. Integrating Sensing and Actuation Emulation Within Your Application Design
      2. Emulating Sensors
      3. Emulating Actuators
      4. Connecting Emulated Sensors with the Sensor Adapter Manager
      5. Connecting Emulated Actuators with the Actuator Adapter Manager
    4. Additional Exercises
      1. Threshold Management
    5. Conclusion
  9. 5. Data Management
    1. What You’ll Learn in This Chapter
    2. Data Translation and Management Concepts
    3. Programming Exercises
      1. Data Translation in the Constrained Device App
      2. Data Translation in the Gateway Device App
    4. Additional Exercises
      1. Proactive Disk Utilization Management
    5. Conclusion
  10. III. Connecting to Other Things
  11. 6. MQTT Integration–Overview and Python Client
    1. What You’ll Learn in This Chapter
    2. About MQTT
      1. Connecting to a Broker
      2. Message Passing
      3. Control Packets and the Structure of an MQTT Message
    3. Adding MQTT to Your Applications
      1. Installing and Configuring an MQTT Broker
    4. Programming Exercises
      1. Create the MQTT Connector Abstraction Module
      2. Add Callbacks to Support MQTT Events
      3. Add Publish, Subscribe, and Unsubscribe Functionality
      4. Integrate the MQTT Connector into Your CDA
      5. What About Security?
    5. Additional Exercises
    6. Conclusion
  12. 7. MQTT Integration–Java Client
    1. What You’ll Learn in This Chapter
    2. Programming Exercises
      1. Create the MQTT Connector Abstraction Module
      2. Add Callbacks to Support MQTT Events
      3. Add Publish, Subscribe, and Unsubscribe Functionality
      4. Integrate the MQTT Connector into Your GDA
      5. What About Security and Overall System Performance?
    3. Additional Exercises
      1. Subscriber Callbacks
      2. CDA to GDA Integration
    4. Conclusion
  13. 8. CoAP Server Implementation
    1. What You’ll Learn in This Chapter
    2. About CoAP
      1. Client to Server Connections
      2. Request Methods
      3. Message Passing
      4. Datagram Packets and the Structure of a CoAP Message
      5. Putting It All Together
    3. Programming Exercises
      1. Add CoAP Server Functionality to the Gateway Device Application
      2. Add CoAP Server Functionality to the Constrained Device Application (Optional)
    4. Additional Exercises
      1. Add More Resource Handlers
      2. Add a Custom Discovery Service
      3. Add Dynamic Resource Creation
    5. Conclusion
  14. 9. CoAP Client Integration
    1. What You’ll Learn in This Chapter
    2. Design Concepts
    3. Programming Exercises
      1. Add CoAP Client Functionality to the Constrained Device Application
      2. Add CoAP Client Functionality to the Gateway Device App (Optional)
    4. Additional Exercises
      1. Add a Robust OBSERVE Cancel Feature
      2. Add Support for DELETE and POST
    5. Conclusion
  15. 10. Edge Integration
    1. What You’ll Learn in This Chapter
    2. Design Concepts
    3. Security Exercises
      1. Adding TLS Support to Your MQTT Broker
      2. Add Security Features to Your Gateway Device App MQTT Client Connector
      3. Add Security Features to Your Constrained Device App MQTT Client Connector
    4. Functional Exercises
      1. Adding Business Logic to the Gateway Device App
      2. Adding Business Logic to the Constrained Device App
    5. Performance Testing Exercises
    6. Additional Exercises
      1. Add DTLS Support to Your CoAP Client and Server
    7. Conclusion
  16. IV. Connecting to the Cloud
  17. 11. Integrating with Various Cloud Services
    1. What You’ll Learn in This Chapter
    2. Design Concepts
    3. Programming Exercises
      1. Add the Cloud Client and Other Related Components
    4. Integrating with an IoT Cloud Service Provider (CSP)
      1. Ubidots Connectivity Overview Using MQTT
      2. AWS IoT Core Connectivity Overview Using MQTT
    5. Additional Exercises
      1. Analyzing and Acting on Time-Series Performance Data
    6. Conclusion
  18. 12. Taming the IoT
    1. What You’ll Learn in This Chapter
      1. IoT Ecosystem Enablers
    2. Sample IoT Use Cases
      1. Shared Enablers and a Common Notional Design
      2. Use Case 1: Home Environment Monitoring and Temperature Adjustment
      3. Use Case 2: Garden Monitoring and Water Adjustment
      4. Use Case 3: Pond Quality Monitoring
    3. Conclusion
  19. A. Design Road Maps
    1. Part I, “Getting Started”—Design Road Maps
      1. Chapter 1 Designs
      2. Chapter 2 Designs
    2. Part II, “Connecting to the Physical World”—Design Road Maps
      1. Chapter 3 Design
      2. Chapter 4 Design
      3. Chapter 5 Designs
    3. Part III, “Connecting to Other Things”—Design Road Maps
      1. Chapter 6 Design
      2. Chapter 7 Design
      3. Chapter 8 Designs
      4. Chapter 9 Designs
      5. Chapter 10 Designs
    4. Part IV, “Connecting to the Cloud”—Design Road Maps
      1. Chapter 11 Designs
  20. Bibliography
  21. Index
  22. About the Author

Product information

  • Title: Programming the Internet of Things
  • Author(s): Andy King
  • Release date: June 2021
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781492081418