xBee Adapter Kit and RasPi using GPIO/UART?

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
uberhund
 
Posts: 154
Joined: Tue Dec 02, 2008 4:06 pm

xBee Adapter Kit and RasPi using GPIO/UART?

Post by uberhund »

I've used the excellent Adafruit xBee Adapter Kit to enable communication between Arduinos for nearly a decade. However, making the transition to the UART function of RasPi has not gone so smoothly.

I've connected the two devices being careful that the xBee Tx line goes to the RasPi GPIO Rx line, and vice versa.
  • 5v Power to xBee Adapter? Check
  • Green and Red LEDs on xBee Adapter illuminate and flash as healthy? Check
  • A script to simply read the data being transmitted by other xBees in the mesh and output to, say, a file, or the PUTTY display?: No joy
Anyone have a favorite script (either PHP or Python) with all the needed includes that is known to work? I've seen various references to "resource temporarily not available" to "access denied" to "expected data but none found" being the typical barrier to getting these scripts to work.

Thoughts?
Last edited by uberhund on Thu Oct 23, 2014 2:54 pm, edited 2 times in total.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: xBee Adapter Kit and RasPi using GPIO/UART?

Post by adafruit_support_mike »

The answers go all the way down to the kernel level, and the short version is, "unix thinks everything is a file".

It's easier to be specific by chopping away a bunch of alternatives. What programming language do you want to use?

User avatar
uberhund
 
Posts: 154
Joined: Tue Dec 02, 2008 4:06 pm

Re: xBee Adapter Kit and RasPi using GPIO/UART?

Post by uberhund »

Thanks so much for the response! My answers below:

...the short version is, "unix thinks everything is a file".
Yep. I've read about an issue called "blocking" related to this otherwise excellent notion within Unix.

What programming language do you want to use?
All of the other server side code I've created for this project is in PHP, so I would nominate PHP as my first choice to keep the portfolio of languages used to a minimum. However, if support is stronger for Python (includes or whatever), I'll make the exception. Heck, depending on the support and chance of success I'd consider Java, or perhaps even C++.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: xBee Adapter Kit and RasPi using GPIO/UART?

Post by adafruit_support_mike »

PHP should work, though I admit my PHP-fu is weak (I'm a Perl snob). ;-)

Do you happen to know what device file/COM port the system creates when you connect the XBee?

User avatar
uberhund
 
Posts: 154
Joined: Tue Dec 02, 2008 4:06 pm

Re: xBee Adapter Kit and RasPi using GPIO/UART?

Post by uberhund »

PHP should work, though I admit my PHP-fu is weak (I'm a Perl snob). ;-)
Sorry, Mike. Did not mean to overlook Perl. A working solution in Perl would be fine also! In any case, the script, when it works, will likely be put into a chron entry, if that matters.


Do you happen to know what device file/COM port the system creates when you connect the XBee?
Hm. It appears that RasPi hardwires device file 'dev/ttyAMA0' to the GPIO Tx/Rx pins. The xBee mesh is running at 9600 baud. Does this cover it?

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: xBee Adapter Kit and RasPi using GPIO/UART?

Post by adafruit_support_mike »

WRT Perl, I was making fun of myself. There's a traditional rivalry between the two languages. ;-)

This page shows how to communicate with a serial port in PHP:

http://www.fritz-hut.com/2012/08/30/php ... spberrypi/

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: xBee Adapter Kit and RasPi using GPIO/UART?

Post by pburgess »

Also need to disable the login console on this port. Here's some info on that:
http://www.hobbytronics.co.uk/raspberry-pi-serial-port

Should be possible to test with commands like:
cat > /dev/ttyAMA0
to type stuff to the port, and
tail -f /dev/ttyAMA0
to read from port.

User avatar
uberhund
 
Posts: 154
Joined: Tue Dec 02, 2008 4:06 pm

Re: xBee Adapter Kit and RasPi using GPIO/UART?

Post by uberhund »

An update: Using Miniterm running on the Pi, I've been able to watch data arrive in perfect condition from the xBee connected thru the GPIO, thus confirming that the two devices are connected correctly. However, the issue of reading the data in a Python, or any other kind of script, remains unsolved.

As I've not seen a working solution to this problem anywhere (either maker shops, tech spaces, college research labs, or through Web searches), the question becomes whether I should abandon the GPIO approach and connect the xBee through the USB port, perhaps using the Adafruit FTDI friend (https://www.adafruit.com/products/284) instead?

Thanks again to pburgess and the admins for your excellent response and guidance on this challenge.

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”