Introduction: Raspberry Pi + Xbee RC Transmitter

About: I can fly at will in my dreams. :-)

This instructable will show you what I did to create my own Raspberry Pi Zero + Xbee RC transmitter

Step 1: Raspberry PI and Xbee RC Transmitter

Step 2: Configure the Raspberry Pi UART

Hey there!

The Raspberry Pi (all variations) are extremely versatile and are now the cornerstone of an ecosystem of many easy to solder add-ons that make these devices REALLY handy. Unfortunately the one thing that Raspberry Pi is missing (currently) is a breakout board or turnkey GPIO interface for XBee (ZigBee) radios. XBee devices are a great way to communicate between all kinds of devices without a lot of dicing and slicing protocols or data formats and make it very easy to integrate USB devices and send their data to other remote devices. To begin, start with any version of the Raspberry Pi. In this Instructable I used a Raspberry Pi zero, and configured the serial console to free up the UART using this Instructable.

Step 3: Write a Python Script to Read Game Controller Values

This bit of Python code reacts to the events raised by the game controller and transmits the value of the input on the control that raised the event. This code will send data as fast as the baud rate set on the XBee radios. In this example the radios are set to 57600 but could be set to their highest baud rate. The game controller is a Logitech USB game controller. The code used is below:

import pygame

import serial

sOut=""

ser=serial.Serial{

port='/dev/ttyAMA0',

baudrate=57600,

parity=serial.PARITY_NONE,

stopbits=serial.STOPBITS_ONE,

bytesize=serial.EIGHTBITS,

timeout=1

}

pygame.init()

done=False

while done==false:

joystick=pygame.joystick.joystick(0)

joystick.init()

#EVENT PROCESSING

for event in pygame.event.get():

if event.type==pygame.JOYAXISMOTION:

sOut="Axis:" + str(event.axis) + ";Value:" + str(event.value)

print(sOut)

ser.write(sOut)

ser.flush()

sOut=""

if event.type==pygame.JOYHATMOTION:

sOut="Hat: + str(event.hat) + ";Value:" + str(event.value)

print(sOut)

ser.write(sOut)

ser.flush()

sOut=""

if event.type==pygame.JOYBUTTONDOWN:

sOut="Button Down:" + str(event.button)

print(sOut)

ser.write(sOut)

ser.flush()

sOut=""

if event.button==8:

print("Quitting")

done=True

if event.type==pygame.JOYBUTTONUP:

sOut="Button Up:" + str(event.button)

print(sOut)

ser.write(sOut)

ser.flush()

sOut=""

ser.close()

pygame.quit()

Step 4: Conclusion

The final build of this uses an auxiliary phone battery to power the Raspberry Pi, which powers the XBee and Logitech game controller. In a future project I will add a vacuum formed plastic cover that will enclose the Raspberry PI Zero, XBee Radio, and power supply, all attached to the game controller in one nice, neat bundle. This RC transmitter build makes it very easy to send control data to just about anything. In my next build I will send the data to a hexapod robot that I rescued from Goodwill. Hope you find this instructable helpful. Happy Building!

Step 5: Wire the Raspberry Pi Zero to the XBee Radio

As shown in the diagram, connect the Pi GPIO pin 1 (3.3v) to XBee pin 1. Connect the Pi GPIO pin 6 (Gnd) to XBee pin 10, and Pi GPIO Pin 8 (TX) to XBee pin 3 (Din). You can also use an XBee breakout board which will require you to connect the Pi GPIO pin 2 (5v) to the 5v pin on the breakout board

Remote Control Contest 2017

Participated in the
Remote Control Contest 2017