I'm trying to use my Raspberry Pi B+ as a gateway so others sensors, also with xbee, can send data and get a few kind of commands by it. The problem is that i can only read the data with the simplest code:
import time
import serial
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(23,GPIO.OUT)
ser = serial.Serial(
port='/dev/ttyS0',
baudrate = 115200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
while 1:
x=ser.readline()
print(x)
but i want to use the xbee-api to have access to write options and another read stuffs. The problem is that i get this error:
pi@raspberrypi:~ $ sudo python3 Desktop/testePython.py
Traceback (most recent call last):
File "Desktop/testePython.py", line 5, in <module>
local_xbee.open()
File "/usr/local/lib/python3.5/dist-packages/digi/xbee/devices.py", line 1259, in open
raise InvalidOperatingModeException("Could not determine operating mode")
digi.xbee.exception.InvalidOperatingModeException: Could not determine operating mode
when i use this code:
from digi.xbee.devices import XBeeDevice
# Instantiate an XBee device object.
local_xbee = XBeeDevice("/dev/ttyS0", 115200)
local_xbee.open()
More details:
Xbee-api library
Xbee model: XBO09-DM
Already went to "raspi-config" to enable the serial interface
Already tried Xbee API Options with =1 and with =2.