serial communications question

XBee projects like the adapter, xBee tutorials, tweetawatt/wattcher, etc. from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
dimosk
 
Posts: 4
Joined: Wed Jun 24, 2009 11:48 am

serial communications question

Post by dimosk »

Hi
I am trying to comminucate to my Xbee with the FTDI cable on COM4. I have been trying to use the pyserial.py code to no avail. The code includes the line "import serial" however i cannot find this bit of code. Running pyserial does cause the system to lock up too. Any ideas on how we can read the data packets off the serial port is appreciated.

Thanks!

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: serial communications question

Post by adafruit »

The code includes the line "import serial" however i cannot find this bit of code
i dont understand what you mean
please spend some time crafting a post that is more understandable

dimosk
 
Posts: 4
Joined: Wed Jun 24, 2009 11:48 am

Re: serial communications question

Post by dimosk »

okay, i will try my best by referencing the instructions from the tweet-a-watt page http://www.ladyada.net/make/tweetawatt/parser.html

We are not able to get past the first step on this page.... specifically our difficulty is in getting the python code to read the com port, in our case COM4. We have put the pyserial module on our computer but it does not include the serial.py statement needed to get us to the serial port. We are using the FTDI cable with the proper drivers and we can get packets of data into the terminal window as per the instructions on the previous steps.

however we cannot run this code:

from xbee import xbee
import serial
SERIALPORT = "COM4" # the com/serial port the XBee is connected to
BAUDRATE = 9600 # the baud rate we talk to the xbee

# open up the FTDI serial port to get data transmitted to xbee
ser = serial.Serial(SERIALPORT, BAUDRATE)
ser.open()

while True:
# grab one packet from the xbee, or timeout
packet = xbee.find_packet(ser)
if packet:
xb = xbee(packet)

print xb

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: serial communications question

Post by adafruit »

did you install pyserial?

dimosk
 
Posts: 4
Joined: Wed Jun 24, 2009 11:48 am

Re: serial communications question

Post by dimosk »

yes indeed, we installed the pyserial module.

We have been able to get it to print one packet of xbee data at a time. This is only possible if we type each line of code manually into the python shell. Otherwise we cannot run the actual code with the "while" and "if" statements we get an error message:

Serial Exception cannot open port COM4

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: serial communications question

Post by adafruit »

it would have been handy if you said what the error was 4 messages ago. :roll:
make sure nothing else is using that port. only one program can access a COM port at time

dimosk
 
Posts: 4
Joined: Wed Jun 24, 2009 11:48 am

Re: serial communications question

Post by dimosk »

Thanks we realized it too. Now we are having problems installing a simplejson module so that we can get wattcher.py to work.

So far we are having some bad luck getting simplejson to add itself as a module in python. Any good links to how we can do this?

Thanks,
Dimos

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: serial communications question

Post by adafruit »

hmm i think you can just stick it in the same folder as the tweetawatt code. its not a happy installing module like the others. you're almost done! :)

Locked
Please be positive and constructive with your questions and comments.

Return to “XBee products (discontinued)”