Raspberry Pi and XBee

XBee perfboard hooked up to the Raspberry Pi
One nice gadget to play with is the quite new Raspberry Pi. I added a XBee (Coordinator AT) to the RasPi and sent some serial data to an Arduino UNO (and back) with a XBee attached (Router AT) via serial terminal (minicom) and Python.

The RasPi is running on Debian wheezy and the perfboard is connected via two row header sockets to the GPIO pins.

The 3.3V for the XBee is directly coming from Pin 1 of the GPIO-Header (GND from Pin 6), DOUT is connected to Pin 10 (GPIO RXD) and DIN to Pin 8 (GPIO TXD). I didn't test it with a XBee Pro attached, this will certainly draw too much current from the RasPi. The 3.3V supply only delivers 50mA as per this wiki . This is fine with the normal XBee which has 40mA max. current demand as per datasheet. If you need more current (XBee PRO needs 295mA@3.3V when transmitting with maximum output power) you could use the 5V power source with a subsequent voltage regulator as mentioned in the blog entries before. Be careful to use a voltage regulator with enough capabilities to deliver ample current.

Still enough legroom for the Raspberry Pi
One big advantage beside being wireless is that there is no level converter needed as the signals are 3.3V TTL to and from the Raspberry Pi.

To get the whole thing working you have to modify some settings in Debian wheezy. There is a nice walkthrough in this blog.

If you want to communicate via Python you have to get pyserial (sudo apt-get install python-serial or sudo apt-get install python3-serial for Python3). Example code for Python2 to send a value to the Arduino would look like this:

import serial

For Python3 you would have to change the last line to:


to send as a String.

On the Arduino side you could read the incoming data with Serial.read().

Connecting the whole thing together gives a huge amount of opportunities for future projects as one can use the combined cpu power/ linux system/ graphic abilities of the Raspberry Pi and the microcotroller skills and shields of the Arduinos - everything wirelessly connected in a mesh network.


  1. Interesting tutorial XBee for Raspberry Pi http://www.cooking-hacks.com/index.php/documentation/tutorials/raspberry-pi-xbee

  2. This comment has been removed by the author.

    1. I found that your post is very impressive to understand XBee module with using Xbee tutorial. Can you tell me about more the working process of Xbee in Linux?

  3. Thanks, nice post. My issue is send AT commands to change MY, ID or whatever programming python, I'm using PySerial. ¿Do you know something about that?