
Get started with MicroPython
MicroPython examples
Digi XBee® 3 802.15.4 RF Module User Guide
43
device_type
: 1179648
parent_nwk
: 65534
sender_nwk
: 0
sender_eui64
: b'\x00\x13\xa2\xff h\x98T'
node_type
: 0
Radio discovered:
rssi
: -75
node_id
: Router
device_type
: 1179648
parent_nwk
: 65534
sender_nwk
: 23125
sender_eui64
: b'\x00\x13\xa2\xffh\x98c&'
node_type
: 1
Examples: transmitting data
This section provides examples for transmitting data using MicroPython. These examples assume you
have followed the above examples and the two radios are on the same network.
Example: transmit message
Use the
xbee
module to transmit a message from the XBee 3 Zigbee device. The
transmit()
function
call consists of the following parameters:
1. The Destination Address, which can be any of the following:
n
Integer for 16-bit addressing
n
8-byte bytes object for 64-bit addressing
n
Constant
xbee.ADDR_BROADCAST
to indicate a broadcast destination
n
Constant
xbee.ADDR_COORDINATOR
to indicate the coordinator
2. The Message as a character string.
If the message is sent successfully,
transmit()
returns
None
. If the transmission fails due to an ACK
failure or lack of free buffer space on the receiver, the sent packet will be silently discarded.
Example: transmit a message to the network coordinator
1. From the router, access the MicroPython environment.
2. At the MicroPython >>> prompt, type
import xbee
and press
Enter
.
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
.
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: