Get started with MicroPython MicroPython networking and communication examples
Digi XBee® 3 Zigbee® RF Module
32
for node in nodes:
print("\nRadio discovered:")
for key, value in node.items():
print("\t{:<12} : {}".format(key, value))
# Set NO back to the default value
xbee.atcmd("NO", 0)
xbee.atcmd("AC")
This produces the following output from two discovered nodes:
Radio discovered:
rssi : -63
node_id : Coordinator
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.