MQTT Essentials - A Lightweight IoT Protocol

Send and receive messages with the MQTT protocol for your IoT solutions.
Preview in Mapt

MQTT Essentials - A Lightweight IoT Protocol

Gastón C. Hillar

7 customer reviews
Send and receive messages with the MQTT protocol for your IoT solutions.
Mapt Subscription
FREE
$29.99/m after trial
eBook
$10.00
RRP $31.99
Save 68%
Print + eBook
$39.99
RRP $39.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$10.00
$39.99
$29.99 p/m after trial
RRP $31.99
RRP $39.99
Subscription
eBook
Print + eBook
Start 14 Day Trial

Frequently bought together


MQTT Essentials - A Lightweight IoT Protocol Book Cover
MQTT Essentials - A Lightweight IoT Protocol
$ 31.99
$ 10.00
ESP8266 Internet of Things Cookbook Book Cover
ESP8266 Internet of Things Cookbook
$ 31.99
$ 10.00
Buy 2 for $20.00
Save $43.98
Add to Cart

Book Details

ISBN 139781787287815
Paperback280 pages

Book Description

This step-by-step guide will help you gain a deep understanding of the lightweight MQTT protocol. We’ll begin with the specific vocabulary of MQTT and its working modes, followed by installing a Mosquitto MQTT broker. Then, you will use best practices to secure the MQTT Mosquitto broker to ensure that only authorized clients are able to publish and receive messages. Once you have secured the broker with the appropriate configuration, you will develop a solution that controls a drone with Python.

Further on, you will use Python on a Raspberry Pi 3 board to process commands and Python on Intel Boards (Joule, Edison and Galileo). You will then connect to the MQTT broker, subscribe to topics, send messages, and receive messages in Python. You will also develop a solution that interacts with sensors in Java by working with MQTT messages.

Moving forward, you will work with an asynchronous API with callbacks to make the sensors interact with MQTT messages. Following the same process, you will develop an iOS app with Swift 3, build a website that uses WebSockets to connect to the MQTT broker, and control home automation devices with HTML5, JavaScript code, Node.js and MQTT messages

Table of Contents

Chapter 1: Lightweight Messaging with MQTT 3.1.1 and Mosquitto
Understanding convenient scenarios for the MQTT protocol
Working with the publish-subscribe pattern
Working with message filtering
Understanding the MQTT puzzle -- clients, servers, and connections
Installing a Mosquitto broker on Ubuntu Linux
Installing a Mosquitto broker on macOS
Installing a Mosquitto broker on Windows
Subscribing to topics
Publishing messages
Unsubscribing from topics
Working with best practices when creating topics
Understanding wildcards
Learning about the different Quality of Service levels
Working with at least once delivery
Working with exactly once delivery
Test your knowledge
Summary
Chapter 2: Securing an MQTT Mosquitto Server
Securing a Mosquitto server
Generating a private certificate authority to use TLS with Mosquitto
Creating a certificate for the Mosquitto server
Configuring TLS transport security in Mosquitto
Testing the MQTT TLS configuration with MQTT.fx
Testing the MQTT TLS configuration with MQTT-spy
Creating a certificate for each MQTT client
Configuring TLS client certificate authentication in Mosquitto
Testing the MQTT TLS client authentication with MQTT.fx
Testing the MQTT TLS configuration with MQTT-spy
Forcing the TLS protocol version
Test your knowledge
Summary
Chapter 3: Controlling a Drone with Python
Understanding the requirements to control a drone with MQTT
Defining the topics and commands
Installing paho-mqtt for Python
Connecting the client to the MQTT server with Python
Understanding callbacks
Subscribing to topics with Python
Creating a class to represent a drone
Receiving messages with Python
Processing commands with Python
Sending messages with Python
Working with the network loop with Python
Test your knowledge
Summary
Chapter 4: Interacting with Sensors in Java
Understanding the requirements
Defining the topics and commands
Installing the Eclipse Paho Java Client
Creating a security helper class to establish a TLS secured connection
Configuring a TLS secured connection in Java
Working with asynchronous notifications and callbacks in Java
Subscribing to topics and understanding notification events in Java
Processing commands that interact with sensors in Java
Working with last will and testament in Java
Publishing messages with commands to target sensors
Test your knowledge
Summary
Chapter 5: Controlling Home Automation in JavaScript
Understanding the requirements
Defining the topics and commands to control home automation
Enabling WebSockets for a Mosquitto server
Testing WebSockets with the Eclipse Paho client JavaScript utility
Understanding the Eclipse Paho JavaScript asynchronous client
Creating an HTML 5 web page to control LEDs
Publishing messages to target remote devices in JavaScript
Processing the received messages in JavaScript
Working with WebSockets to connect to the MQTT server
Subscribing to topics in JavaScript
Processing commands that interact with LEDs in Node.js
Running the home automation web application
Debugging asynchronous code with Chrome Developer Tools (CDT) in JavaScript
Securing MQTT over WebSockets with TLS
Test your knowledge
Summary
Chapter 6: Interacting with Actuators in Swift
Understanding the requirements
Defining topics and commands
Enabling connections without TLS for a Mosquitto server
Installing the CocoaMQTT client library to create a new iOS app
Building the UI for the iOS app that will control an actuator
Understanding the CocoaMQTT client in Swift 3
Connecting to the MQTT server and subscribing to topics in Swift
Publishing messages to target actuators in Swift
Processing commands that interact with actuators in Node.js
Running the iOS app that controls an actuator with MQTT
Debugging events in Swift
Test your knowledge
Summary

What You Will Learn

  • Understand how MQTTv3.1 and v3.1.1 works in detail
  • Install and secure a Mosquitto MQTT broker by following best practices
  • Design and develop IoT solutions combined with mobile and web apps that use MQTT messages to communicate
  • Explore the features included in MQTT for IoT and Machine-to-Machine communications
  • Publish and receive MQTT messages with Python, Java, Swift, JavaScript, and Node.js
  • Implement the security best practices while setting up the MQTT Mosquitto broker

Authors

Table of Contents

Chapter 1: Lightweight Messaging with MQTT 3.1.1 and Mosquitto
Understanding convenient scenarios for the MQTT protocol
Working with the publish-subscribe pattern
Working with message filtering
Understanding the MQTT puzzle -- clients, servers, and connections
Installing a Mosquitto broker on Ubuntu Linux
Installing a Mosquitto broker on macOS
Installing a Mosquitto broker on Windows
Subscribing to topics
Publishing messages
Unsubscribing from topics
Working with best practices when creating topics
Understanding wildcards
Learning about the different Quality of Service levels
Working with at least once delivery
Working with exactly once delivery
Test your knowledge
Summary
Chapter 2: Securing an MQTT Mosquitto Server
Securing a Mosquitto server
Generating a private certificate authority to use TLS with Mosquitto
Creating a certificate for the Mosquitto server
Configuring TLS transport security in Mosquitto
Testing the MQTT TLS configuration with MQTT.fx
Testing the MQTT TLS configuration with MQTT-spy
Creating a certificate for each MQTT client
Configuring TLS client certificate authentication in Mosquitto
Testing the MQTT TLS client authentication with MQTT.fx
Testing the MQTT TLS configuration with MQTT-spy
Forcing the TLS protocol version
Test your knowledge
Summary
Chapter 3: Controlling a Drone with Python
Understanding the requirements to control a drone with MQTT
Defining the topics and commands
Installing paho-mqtt for Python
Connecting the client to the MQTT server with Python
Understanding callbacks
Subscribing to topics with Python
Creating a class to represent a drone
Receiving messages with Python
Processing commands with Python
Sending messages with Python
Working with the network loop with Python
Test your knowledge
Summary
Chapter 4: Interacting with Sensors in Java
Understanding the requirements
Defining the topics and commands
Installing the Eclipse Paho Java Client
Creating a security helper class to establish a TLS secured connection
Configuring a TLS secured connection in Java
Working with asynchronous notifications and callbacks in Java
Subscribing to topics and understanding notification events in Java
Processing commands that interact with sensors in Java
Working with last will and testament in Java
Publishing messages with commands to target sensors
Test your knowledge
Summary
Chapter 5: Controlling Home Automation in JavaScript
Understanding the requirements
Defining the topics and commands to control home automation
Enabling WebSockets for a Mosquitto server
Testing WebSockets with the Eclipse Paho client JavaScript utility
Understanding the Eclipse Paho JavaScript asynchronous client
Creating an HTML 5 web page to control LEDs
Publishing messages to target remote devices in JavaScript
Processing the received messages in JavaScript
Working with WebSockets to connect to the MQTT server
Subscribing to topics in JavaScript
Processing commands that interact with LEDs in Node.js
Running the home automation web application
Debugging asynchronous code with Chrome Developer Tools (CDT) in JavaScript
Securing MQTT over WebSockets with TLS
Test your knowledge
Summary
Chapter 6: Interacting with Actuators in Swift
Understanding the requirements
Defining topics and commands
Enabling connections without TLS for a Mosquitto server
Installing the CocoaMQTT client library to create a new iOS app
Building the UI for the iOS app that will control an actuator
Understanding the CocoaMQTT client in Swift 3
Connecting to the MQTT server and subscribing to topics in Swift
Publishing messages to target actuators in Swift
Processing commands that interact with actuators in Node.js
Running the iOS app that controls an actuator with MQTT
Debugging events in Swift
Test your knowledge
Summary

Book Details

ISBN 139781787287815
Paperback280 pages
Read More
From 7 reviews

Read More Reviews

Recommended for You

ESP8266 Internet of Things Cookbook Book Cover
ESP8266 Internet of Things Cookbook
$ 31.99
$ 10.00
IoT Projects with Bluetooth Low Energy Book Cover
IoT Projects with Bluetooth Low Energy
$ 27.99
$ 10.00
Raspberry Pi Zero W Wireless Projects Book Cover
Raspberry Pi Zero W Wireless Projects
$ 27.99
$ 10.00
Practical Internet of Things with JavaScript Book Cover
Practical Internet of Things with JavaScript
$ 27.99
$ 10.00
Statistics for Machine Learning Book Cover
Statistics for Machine Learning
$ 39.99
$ 10.00
Statistics for Machine Learning Book Cover
Statistics for Machine Learning
$ 39.99
$ 10.00