EasyManuals Logo
Home>Digi>Control Unit>XBee 3 ZigBee

Digi XBee 3 ZigBee User Manual

Digi XBee 3 ZigBee
347 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 #33 background imageLoading...
Page #33 background image
Get started with MicroPython MicroPython networking and communication examples
Digi XBe 3 Zigbe RF Module
33
3. At the MicroPython >>> prompt, type xbee.transmit(xbee.ADDR_COORDINATOR, "Hello
World!") and press Enter.
4. On the coordinator, you can issue an xbee.receive() call to output the received packet.
Example: transmit custom messages to all nodes in a network
This program performs a network discovery and sends the message 'Hello <Destination Node
Identifier>!' to individual nodes in the network. For more information, see Example: network
Discovery using MicroPython.
import xbee
# Perform a network discovery to gather destination address:
print("Discovering remote nodes, please wait...")
node_list = list(xbee.discover())
if not node_list:
raise Exception("Network discovery did not find any remote devices")
for node in node_list:
dest_addr = node['sender_nwk'] # 'sender_eui64' can also be used
dest_node_id = node['node_id']
payload_data = "Hello, " + dest_node_id + "!"
try:
print("Sending \"{}\" to {}".format(payload_data, hex(dest_addr)))
xbee.transmit(dest_addr, payload_data)
except Exception as err:
print(err)
print("complete")
Receiving data
Use the receive() function from the xbee module to receive messages. When MicroPython is active on
a device (AP is set to 4), all incoming messages are saved to a receive queue within MicroPython. This
receive queue is limited in size and only has room for 4 messages. To ensure that data is not lost, it is
important to continuously iterate through the receive queue and process any of the packets within.
If the receive queue is full and another message is sent to the device, it will not acknowledge the
packet and the sender generates a failure status of 0x24 (Address not found).
The receive() function returns one of the following:
n None: No message (the receive queue is empty).
n Message dictionary consisting of:
l sender_nwk: 16-bit network address of the sending node.
l sender_eui64: 64-bit address (as a "bytes object") of the sending node.
l source_ep: source endpoint as an integer.
l dest_ep: destination endpoint as an integer.
l cluster: cluster id as an integer.
l profile: profile id as an integer.
l broadcast: True or False depending on whether the frame was broadcast or unicast.
l payload: "Bytes object" of the payload. This is a bytes object instead of a string, because
the payload can contain binary data.

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

Digi XBee 3 ZigBee Specifications

General IconGeneral
BrandDigi
ModelXBee 3 ZigBee
CategoryControl Unit
LanguageEnglish

Related product manuals