I’ve been going round in circles for days trying to do this.
I seem to be stuck down a small hole between everything I have read.
I’m using 2 (soon to be more) XBee 3 modules and I simply want to output some control data out of a sparkfun 232 explorer to a third-party device.
I’m using MicroPython as I don’t want any of the XBee packet data to go out with it.
I am successfully sending data from one XBee to another using its Node Identifier and the receiving XBee will print this out in REPL, but I need this to go out of the 232 shield.
I thought I would need to send it out of a UART port but I get “ImportError: cannot import name UART” so looks like I’m barking up the wrong tree.
This all works fine if I set the receiving XBee to API but as I said, I need the data to be “clean” so am using MicroPython.
This is the example code I’m using that works up to receiving the data
while True:
# Check if the XBee has any message in the queue.
received_msg = xbee.receive()
if received_msg:
# Get the sender’s 64-bit address and payload from the received message.
sender = received_msg[‘sender_eui64’]
payload = received_msg[‘payload’]
print(“Data received from %s >> %s” % (‘’.join(‘{:02x}’.format(x).upper() for x in sender),
payload.decode()))
What am I looking for here to send data out? Serial? UART? an IO?
If ATAP=4, then print() will send data out the serial port (because REPL output is directed to the serial port).
If ATAP=1, then you can use User Data Relay frames to send data between MicroPython and your host processor, but it will need to parse the frames.
If ATAP=0, then any data you send to the module (in a “transmit” frame with default endpoint/cluster/profile settings) will just go out the serial port without any intervention. You wouldn’t need to make use of MicroPython at all.
Ah! Didn’t realise that the REPL output went straight out… it was working the whole time but I didn’t check it as I thought I needed to send it somewhere else.