Do... or do not. There is no try. - Yoda

Raspberry Pi BB-8



I saw this project on YouTube and decided to try it out.

Thanks to his video and Joseph Kim's GitHub page I was finally able to get this project off the ground. His code is adapted from (and uses code from) davinellulinvega's and ali1234's repos as well so be sure to check out them out while you're there.

This page is a guide on how I got Joseph's code working on a Raspberry Pi 2 with a BTLE Dongle as well as a Raspberry Pi 3 using its built-in BTLE functionality.

Raspberry Pi 2

This is the dongle I'm using.

  1. 1 Download Jessie
  2. 2 Format SD card with the HP USB Disk Format Tool
  3. 3 Write Jessie image to SD card using Win32DiskImager
  4. 4 Eject your SD card from your computer and put it in your Raspberry Pi
  5. 5 Plug in your keyboard, xbox 360 controller, BTLE Dongle, Ethernet cable, and HDMI cable.
  6. 6 Plug in power and let your Pi boot up. (It will probably boot to the Desktop but this is okay.)
  7. 7 On a computer SSH into your Pi using Putty (you'll need to get your Pi's IP from the Pi or your network settings)
  8. 8 First thing you want to do is run sudo apt-get update and then run sudo apt-get upgrade (upgrade can take awhile) finally run sudo apt-get clean See here for more info.
  9. 9 Reboot your Raspberry Pi sudo reboot
  10. 10 Launch Raspi Config sudo raspi-config
  11. 11 Expand Filesystem
  12. 12 Under Boot Options select B1 Console
  13. 13 Click OK and then Finish and reboot your Pi again


Now that that's done, let's set up your Pi to talk with BB-8

Run these commands on the Putty SSH session:
  1. 1 sudo apt-get install python-pip libglib2.0-dev
  2. 2 sudo pip install bluepy
  3. 3 mkdir BB8
  4. 4 cd BB8
  5. 5 wget https://github.com/jjinking/SpheroBB8-python/archive/master.zip
  6. 6 unzip master.zip
  7. 7 cd SpheroBB8-python-master
  8. 8 Run the ls command you should see a couple .py files and a README.md file. These are the python programs we need to control BB8.
  9. 9 Run sudo hcitool lescan and look for something like this: XX:XX:XX:XX:XX:XX BB-7CA6 the XX:XX:XX:XX:XX:XX is your BB8's MAC address and we'll need that in a second. So copy and paste it somewhere. Press CTRL+C to stop the scan.
  10. 10 Run sudo nano BB8_driver.py and replace the MAC_ADDR address with your BB8's MAC address once you've updated the MAC address press CTRL+O (oh, not zero), Enter, and then CTRL+X to save and close.
  11. 11 To test the connection run:sudo python BB8test.py
    The lights should blink. First the light will be white and once it's connected it will cycle through red, blue, and green. Once the program is done it will disconnect from the BB8 and the light will turn orange meaning it's been disconnected.


If the lights blink, congratulations!! Your Pi can talk to your BB8! Next we'll test the Xbox Controller.
  1. 1 Run sudo python BB8joyDrive.py
    If you're not running this through SSH on a different computer, a window should pop up with a graph. The green dot in the middle is the left joystick on the Xbox Controller. Push the buttons and watch BB8 respond.
  2. 2 Move the joystick around and BB8 should move, too.
  3. 3 That's it. Congratulations on getting BB8 working with your Raspberry Pi 2!!


Raspberry Pi 3

Run these commands on the Putty SSH session:
  1. 1 Run sudo apt-get update Next run sudo apt-get upgrade (this can take awhile) Finally run sudo apt-get clean
    See here for more info.
  2. 2 Reboot your Raspberry Pi sudo reboot
  3. 3 Launch Raspi Config sudo raspi-config
  4. 4 Expand Filesystem
  5. 5 Under Boot Options select B1 Console
  6. 6 Click OK and then Finish and reboot your Pi again
  7. 7 sudo apt-get install python-pip libglib2.0-dev
  8. 8 sudo pip install bluepy
  9. 9 mkdir BB8
  10. 10 cd BB8
  11. 11 wget https://github.com/jjinking/SpheroBB8-python/archive/master.zip
  12. 12 unzip master.zip
  13. 13 cd SpheroBB8-python-master
  14. 14 Run the ls command you should see a couple .py files and a README.md file. These are the python programs we need to control BB8.
  15. 15 Run sudo hcitool lescan and look for something like this: XX:XX:XX:XX:XX:XX BB-7CA6 the XX:XX:XX:XX:XX:XX is your BB8's MAC address and we'll need that in a second. So copy and paste it somewhere. (Press CTRL+C to stop the scan.)
  16. 16 Run sudo nano BB8_driver.py and replace the MAC_ADDR address with your BB8's MAC address once you've updated the MAC address press CTRL+O (oh, not zero), Enter, and then CTRL+X to save and close.
  17. 17 To test the connection run:sudo python BB8test.py
    The lights should blink. First the light will be white and once it's connected it will cycle through red, blue, and green. Once the program is done it will disconnect from the BB8 and the light will turn orange meaning it's been disconnected.


If the lights blink, congratulations!! Your Pi can talk to your BB8! Next we'll test the Xbox Controller
  1. 1 Run sudo python BB8joyDrive.py
    If you're not running this through SSH on a different computer, a window should pop up with a graph. The green dot in the middle is the left joystick on the Xbox Controller. Push the buttons and watch BB8 respond.
  2. 2 Move the joystick around and BB8 should move, too.
  3. 3 That's it. Congratulations on getting BB8 working with your Raspberry Pi 2!!

Follow Me