I am trying to blink an LED using a router AT XBee which is controlled by a coordinator API Xbee. The coordinator Xbee is connected to a Raspberry Pi which runs the following program. The LED blinks consistently for exactly 4 cycles but after that, it blinks inconsistently (gets stuck and doesnt light and then blinks super fast, again gets stuck). Sometimes, even after the program is stopped, the LED blinks after few seconds. What is causing the delay and inconsistency, I failed to figure out. I’d appreciate any pointers. Thanks. Baud Rate: 9600
from xbee import XBee, ZigBee
import serial
import time
ser = serial.Serial(‘/dev/ttyUSB0’, 9600)
xbee = ZigBee(ser)
while True:
try:
xbee.send(‘remote_at’,
frame_id=‘A’,
dest_addr_long=‘\x00\x00\x00\x00\x00\x00\xFF\xFF’,
dest_addr=‘\xFF\xFE’,
options=‘\x02’,
command=‘P2’,
parameter=‘\x05’)
time.sleep(1)
xbee.send('remote_at',
frame_id='A',
dest_addr_long='\x00\x00\x00\x00\x00\x00\xFF\xFF',
dest_addr='\xFF\xFE',
options='\x02',
command='P2',
parameter='\x04')
time.sleep(1)
except KeyboardInterrupt:
break
xbee.send(‘remote_at’,
frame_id=‘A’,
dest_addr_long=‘\x00\x00\x00\x00\x00\x00\xFF\xFF’,
dest_addr=‘\xFF\xFE’,
options=‘\x02’,
command=‘P2’,
parameter=‘\x04’)
ser.close()