I have three devices set up in XCTU, COORD, END1 and END2. They are all on the same network. In XCTU when I discover nodes in the same network they all show up in each others radio networks.
My code however will only send to one of them. Can anyone tell me why? Also I set up END1, created a profile. Loaded that profile onto END2 and changed the name to ensure they would all be on the same network.
while True:
adc_value = adc_pin.read()
print(“- ADC value:”, adc_value)
for device in network_devices:
addr16 = device[‘sender_nwk’]
addr64 = device[‘sender_eui64’]
value_sent = False
try:
# Some protocols do not have 16-bit address. In those cases, use the 64-bit one.
xbee.transmit(addr16 if addr16 else addr64, str(adc_value))
value_sent = True
except Exception as e:
value_sent = False
if value_sent:
print("Sent data to: " + device['node_id'])
print(device)
else:
print("Data not sent to: " + device['node_id'])
print(device)
time.sleep(5)
def find_device(node_id):
“”"
Finds the XBee device with the given node identifier in the network and
returns it.
:param node_id: Node identifier of the XBee device to find.
:return: The XBee device with the given node identifier or ``None`` if it
could not be found.
"""
for dev in xbee.discover():
if dev['node_id'] == node_id:
return dev
return None
print(“Sending data to %s >> %s” % (TARGET_NODE_ID, MESSAGE))
try:
# Some protocols do not have 16-bit address. In those cases, use the 64-bit one.
xbee.transmit(addr16 if addr16 else addr64, MESSAGE)
print(“Data sent successfully”)
except Exception as e:
print(“Transmit failure: %s” % str(e))