Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
In the previous blog, I introduced what SAP Korea team did with Sphero and its overall architecture. In this blog, I’ll explain how we control the Sphero using Raspberry Pi and Xbox 360 controller.

Now, we’re in the second blog as below.

HCP IoT Showcase using Sphero
Part 1: Overview
Part 2: Controlling Sphero using Raspberry Pi and Xbox 360 controller
Part 3: Maze Setup (Hardware)
Part 4: Unit Test (Gathering & Sending Data)
Part 5: Unit Test (MQTT)
Part 6: Integration Test
Part 7: XS Application
Part 8: UI

This blog explains the highlighted section in the overall architecture.

As you know, Sphero is originally controlled by official apps on your smartphone but SAP Korea team used Xbox 360 Controller instead for this showcase.


Following things are required in order to implement this part.

  • Raspberry Pi 3 Model B

  • Microsoft Xbox 360 Wired Controller

  • Sphero SPRK or BB-8

Raspberry Pi 2 with Wi-Fi and BLE (Bluetooth low energy) supported bluetooth dongles will work but in this blog, I assume that you have a Raspberry Pi 3 Model B. Similarly, I believe other usb game controllers can be applicable but I also assume that you have a Xbox 360 controller.

Raspberry Pi 3 Setup

The first thing you need to do is obviously installing the OS, Raspbian Jessie. For your reference, I installed the following version.

Raspbian Jessie
Version: May 2016
Release date: 2016.05.27
Kernel version: 4.4

Since many blogs and websites already explained this Raspbian installation step, let me skip it in this blog.

The second step you need to do is installing bluetooth packages for pairing with Sphero and Unofficial SDKs from Sphero website are available as below.

In this blog, I'll leverage the Unofficial SDKs - Python.

Since the bluetooth communication method of Sphero SPRK (Bluetooth Virtual Serial Port) is different from that of Sphero BB-8 (BLE), let me explain Sphero BB-8 first and then Sphero SPRK.

Sphero BB-8

In order to pair with Sphero BB-8, installing Ian Harvey’s bluepy on your Raspberry Pi 3 is required as below.
sudo apt-get install python-pip libglib2.0-dev
sudo pip install bluepy

The next step is preparing Python codes for pairing and controlling Sphero. Thanks to jchadwhite’s great work, you can download or clone the code from here.

All you need to do is copying two files (, to your Raspberry Pi 3 and change MAC address in file. Assume that your Sphero BB-8 is ready to connect, you can identify its MAC address using the following command.
sudo hcitool lescan

The result you need to find will look like this.

DF:79:DD:9C:B6:1D  BB-E804

Once you noted down Sphero BB-8’s MAC address, then you need to modify the code as below (line 244).
sudo nano

Then plug your Xbox 360 Controller to your Raspberry Pi 3 and run on you Raspberry Pi. This code will only work on GUI environment (X Window System).

That’s it. Now enjoy controlling Sphero with your Xbox 360 Controller!

Sphero SPRK

In order to pair with Sphero SPRK, I installed two more packages additionally as below.
sudo apt-get install bluetooth
sudo apt-get install python-bluez

Then, download or clone from the Unofficial SDKs - Python which I introduced above section.

By leveraging the again, I just renamed it to and changed the code as below to import instead of (line 7 to 10).



Once you run on GUI environment, you will see Python code is finding Sphero and pairing with it.

Now you can control Sphero SPRK with your Xbox 360 Controller.

Additional Information

Gathering data from Sphero was not implemented in this showcase but you can also try it using many get and set functions in and

Again, hope these blog series help you to get some insight and let me get back to you soon with next posting.