Quicknote: Raspberry Pi > Python > Serial (Updated)

wpsuperadmin python, raspberry pi, serial, xbee 1 Comment

Here is a quick note on using USB serial with Python. I hooked up a Sparkfun explorer board with a Xbee series 1. Sparkfun Xbee Explorer https://www.sparkfun.com/products/8687 First you need to install the Serial library: apt-get install python-serial The Sparkfun adapter uses FTDI so it shows up as /dev/ttyUSB0 I found this, it works really well. Simple TCP/IP bridgehttp://pyserial.sourceforge.net/examples.html#tcp-ip-serial-bridge I started with this link:http://www.doctormonk.com/2012/04/raspberry-pi-and-arduino.html I couldn’t get it to show data from the Xbee at first so I used Minicom to test:http://codeandlife.com/2012/07/29/arduino-and-raspberry-pi-serial-communication/#more-859 Somehow it started working once I saw data using Minicom. Here is the final code to test read from serial with Python [xbee_read.py] #!/usr/bin/pythonimport serialser = serial.Serial(‘/dev/ttyUSB0’, 9600)ser.open()try: while 1 : result = ser.readline() print result except KeyboardInterrupt: ser.close() …