Home/Support/Support Forum/Xbee terminal output to txt file ?
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Xbee terminal output to txt file ?

0 votes
Hi so I'm using the XBee to do some indoor tracking, Im pinging 3 routers using a transmitter and using the RSSI values to estimate the distances. The distances are printed out in the terminal. Is there a way for me to get this output printed into a txt file? My code is shown below, thank you for your help.


import xbee


A = -33.874
N = -17.27
EULER = 2.718281828


class Transmitter:
def __init__(self, device_dict):
self.device_dict = device_dict

def ComputeDistance(self, rssi):
return EULER**((rssi-A)/N)

# Display date in the form
# node id : rssi dBm, distance m
def DisplayData(self, device, distance):

string = ''.join([str(device), " : ", str(device), " dBm, ", str(distance), " m"])
print(string)

def LocateDevice(self):
for dev in xbee.discover():
if dev in self.device_dict:
dist = self.ComputeDistance(dev)
self.DisplayData(dev, dist)


device_dict = {
'RECEIVER_A': 'RECEIVER_A',
'RECEIVER_B': 'RECEIVER_B',
'RECEIVER_C': 'RECEIVER_C'
}

TX = Transmitter(device_dict)

for i in range(5):
TX.LocateDevice()
asked Nov 4, 2020 in Console Servers by xbeeindoortracking New to the Community (1 point)

Please log in or register to answer this question.

1 Answer

+1 vote
See http://cms.digi.com/resources/documentation/digidocs/90002219/#reference/r_access_data.htm?Highlight=writing%20to%20a%20file
answered Nov 5, 2020 by mvut Veteran of the Digi Community (14,352 points)
Xbee acts as a flash drive it can't write to the pc directly. I am not sure how'd implement this in my code
No, not quite. The XBee acts as a CABLE and not a flash drive. So you would have to adjust your application code to do what you want.
...