Send Data from XBee3 Module to PC via USB Cable

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Dyrestium
Posts: 4
Joined: Fri Jun 07, 2019 4:30 pm

Send Data from XBee3 Module to PC via USB Cable

Post by Dyrestium » Fri Jun 07, 2019 4:54 pm

Hello Forum,

first of all i would like to apologize for my little knowledge. I'm trying hard to learn and hope you won't be insulted if my question is stupid.

I'm currently building a wireless Network using two XBee3 ZigBee Rf Modules from Digi International. These Modules have their own MC's attached and run Micropython on them.
I'm able to send data between the XBee's so all the ZigBee paramters (Adressing, Security,..) are configured correctly.
The first XBee is powered by an external battery and gets input from a analog sensor. That data is being send (wireless) to the second XBee which is connected to my Windows PC with a USB Cable.

My Question: How can i send the received sensor Data on the PC-connected XBee through the USB Connection to my PC and write the data (ints between 0-1024) into a text file (for example).
I already read the entire documentation from Digi about this but couldn't find a solution. The explanations seem to stop, once the data arrives on the second XBee. I hope this is possible with Micropython.

Thank you all so much for helping :roll:

OutoftheBOTS_
Posts: 579
Joined: Mon Nov 20, 2017 10:18 am

Re: Send Data from XBee3 Module to PC via USB Cable

Post by OutoftheBOTS_ » Fri Jun 07, 2019 8:57 pm

I have done this via USB myself.

On the PC I opened a serail port on the USB like this https://pyserial.readthedocs.io/en/late ... intro.html
Then on the Micro-python MCU I attached a URAT to serial converter like this 1 https://www.aliexpress.com/item/1PCS-CP ... 11235f9062 then on the MCU I opened a UART port like this http://docs.micropython.org/en/v1.9.3/p ... .UART.html then I and send and receive between the PC and the MCU.

It is possible to use the USB on the MCU but is much more complex and problematic be the repl is already using the USB and that's why I use the UART with the UART to USB converter

User avatar
pythoncoder
Posts: 3422
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Send Data from XBee3 Module to PC via USB Cable

Post by pythoncoder » Sat Jun 08, 2019 7:41 am

An FTDI cable is your friend if you don't want to tangle with AliExpress. It converts UART signals to USB. There are many suppliers, this one is from Sparkfun.
Peter Hinch

Dyrestium
Posts: 4
Joined: Fri Jun 07, 2019 4:30 pm

Re: Send Data from XBee3 Module to PC via USB Cable

Post by Dyrestium » Sun Jun 09, 2019 1:18 pm

Thanks for the advice. This solved the problem for me:

# Python program on PC
from digi.xbee.devices import ZigBeeDevice
import sys

# Initiate a serial connection with the
# connected XBee3 on the specified port and baud-rate
xbee = ZigBeeDevice("COM1", 9600)
xbee.open()

# Read the XBee's received messages
while True:
# Read the first message from the Queue (First come first serve)
# Blocks until data is received
m = xbee.read_data(sys.maxsize)

# Handle the messages accordingly

Post Reply