EasyManua.ls Logo

Digi XBee 3 User Manual

Digi XBee 3
293 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #78 background imageLoading...
Page #78 background image
Examples: IOT protocols with transparent mode Get started with MQTT
Digi XBe 3 Cellular LTE Cat 1 AT&T Smart Modem User Guide
78
mqttc.loop_start() # Start networking daemon
mqttc.publish("digitest/test1", "Hello, World!") # Publish message to
“digitest /test1 topic
mqttc.loop_stop() # Kill networking daemon
Note You can easily copy and paste code from the online version of this guide. Use caution with the
PDF version, as it may not maintain essential indentations.
This example imports the MQTT library, allowing you to use the MQTT protocol via APIs in the library,
such as the connect(), subscribe(), and publish() methods.
The second line creates an instance of the client, named mqttc. The client ID is the argument you
passed in: digitest (this is optional).
In line 3, the client connects to a public broker, in this case m2m.eclipse.org, on port 1883 (the default
MQTT port, or 8883 for MQTT over TLS). There are many publicly available brokers available, you can
find a list of them here: https://github.com/mqtt/mqtt.github.io/wiki/brokers.
Line 4 starts the networking daemon with client.loop_start() to handle the background
network/data tasks.
Finally, the client publishes its message Hello, World! to the broker under the topic
digitest/backlog/test1. Any nodes (devices, phones, computers, even microcontrollers) subscribed to
that same topic on the same broker receive the message.
Once no more messages need to be published, the last line stops the network daemon with
client.loop_stop().
Example: receive messages (subscribe) with MQTT
This example describes how a client would receive messages from within a specific topic on the
broker:
import paho.mqtt.client as mqtt
def on_connect(client, userdata, flags, rc): # The callback for when the
client connects to the broker
print("Connected with result code {0}".format(str(rc))) # Print result
of connection attempt
client.subscribe("digitest/test1") # Subscribe to the topic
“digitest/test1”, receive any messages published on it
def on_message(client, userdata, msg): # The callback for when a PUBLISH
message is received from the server.
print("Message received-> " + msg.topic + " " + str(msg.payload)) #
Print a received msg
client = mqtt.Client("digi_mqtt_test") # Create instance of client with
client ID digi_mqtt_test
client.on_connect = on_connect # Define callback function for successful
connection
client.on_message = on_message # Define callback function for receipt of a
message
# client.connect("m2m.eclipse.org", 1883, 60) # Connect to (broker, port,
keepalive-time)
client.connect('127.0.0.1', 17300)

Table of Contents

Other manuals for Digi XBee 3

Question and Answer IconNeed help?

Do you have a question about the Digi XBee 3 and is the answer not in the manual?

Digi XBee 3 Specifications

General IconGeneral
ModelXBee 3
CategoryModem
Frequency Bands2.4 GHz, 868 MHz, 900 MHz
InterfaceUART, SPI, I2C
Operating Temperature-40° C to +85° C
Power Supply2.1V to 3.6V
AntennaExternal or onboard
Transmit Powerup to 20 dBm
SecurityAES encryption
ProtocolsZigbee, 802.15.4, DigiMesh

Summary

Getting Started with the XBee Smart Modem

Connect Hardware and Install XCTU

Step-by-step instructions for connecting hardware and installing XCTU utility.

Update Firmware and Check Connection

Procedures for updating device firmware and verifying cellular connection status.

XBee Connection Examples

Getting Started with MicroPython

MicroPython Basics and Setup

Introduction to MicroPython and setting up the environment using XCTU.

Update the Firmware

Update Device and Cellular Firmware

Procedures for updating device and cellular firmware using XCTU.

Update Telit Modem Firmware with XFP Utility

Instructions for updating the Telit modem firmware using the XFP utility.

AT Commands Reference

Special, Cellular, and Network Commands

Reference for special, cellular, and network configuration AT commands.

I/O, Sleep, and Mode Commands

Configuration commands for I/O settings, sleep modes, and operating modes.

File System, BLE, Socket, and API Commands

Commands for file system, BLE, sockets, and API frame management.

Troubleshooting Guide

Related product manuals