September 2017
Intermediate to advanced
206 pages
4h 34m
English
All XBee applications should import the xbee DigiMesh library for Python. We can set the serial port for each XBee module. You can change this serial port to one of your liking.
import time from xbee import DigiMesh import serial #PORT = 'COM7' PORT = '/dev/cu.usbserial-A9CNVHXX' BAUD_RATE = 9600 # Open serial port ser = serial.Serial(PORT, BAUD_RATE) # Create API object xbee = DigiMesh(ser, escaped=True) import pprint pprint.pprint(xbee.api_commands)
In the XBee reader application, we listen for incoming messages from XBee by calling the wait_read_frame() function. After a message is received, we decode the data by calling the decodeReceivedFrame() function.
while True: try: data = xbee.wait_read_frame() decodedData = decodeReceivedFrame(data) ...
Read now
Unlock full access