Get Started With Mqtt; Example: Mqtt Connect - Digi XBee 3 Cellular LTE-M User Manual

Smart modem
Table of Contents

Advertisement

Examples: IOT protocols with transparent mode

Get started with MQTT

MQ Telemetry Transport (MQTT) is a messaging protocol that is ideal for the Internet of Things (IoT)
due to a light footprint and its use of the publish-subscribe model. In this model, a client connects to a
broker, a server machine responsible for receiving all messages, filtering them, and then sending
messages to the appropriate clients.
The first two MQTT examples do not involve the XBee Smart Modem. They demonstrate using the
MQTT libraries because those libraries are required for
a
PC.
The examples in this guide assume:
Some knowledge of Python.
n
An integrated development environment (IDE) such as PyCharm, IDLE or something similar.
n
The examples require:
An XBee Smart Modem.
n
A compatible development board.
n
XCTU. See
n
That you install Python on your computer. You can download Python from:
n
https://www.python.org/downloads/.
That you install the pyserial and paho-mqtt libraries to the Python environment. If you use
n
Python 2, install these libraries from the command line with pip install pyserial and pip
install paho-mqtt. If you use Python 3, use pip3 install pyserial and pip3 install paho-mqtt.
The full MQTT library source code, which includes examples and tests, which is available in the
n
paho-mqtt github repository at https://github.com/eclipse/paho.mqtt.python. To download this
repository you must have Git installed.

Example: MQTT connect

This example provides insight into the structure of packets in MQTT as well as the interaction
between the client and broker. MQTT uses different packets to accomplish tasks such as connecting,
subscribing, and publishing. You can use XCTU to perform a basic example of sending a broker a
connect packet and receiving the response from the server, without requiring any coding. This is a
good way to see how the client interacts with the broker and what a packet looks like. The following
table is an example connect packet:
Description
CONNECT packet fixed header
byte 1
Control packet type
byte 2
Remaining length
CONNECT packet variable header
Protocol name
Digi XBee® 3 Cellular LTE-M/NB-IoT Global Smart Modem User Guide
Install and upgrade
XCTU.
Get started with MQTT
Use MQTT over the XBee Cellular Modem with
Hex value
0x10
0x10
71

Advertisement

Table of Contents
loading

This manual is also suitable for:

Xbee 3 cellular nb-iot

Table of Contents