Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Raspberry Pi Robot - Android Remote Control (Bluetooth)#

Remote control of a Raspberry Pi robot from an Android device using Bluetooth.

Hardware Requirements

The Raspberry Pi code was developed using a Raspberry Pi 3 Model B and:

The Android app was developed with MIT App Inventor and should run on any Android smartphone or tablet equipped with Bluetooth.

Software Requirements

Bluetooth needs to be installed and configured on the Raspberry Pi.

First, ensure the Bluetooth packages are installed:

sudo apt-get install bluez python-bluez

It was previously recommended that PNAT be disabled by adding the line DisablePlugins = pnat to /etc/bluetooth/main.conf, however that key is not recognised by the current version of bluetoothd (5.23) and the underlying Debian bug appears to have been resolved.

The Bluetooth daemon needs to run in compatibility mode so that the serial port service can be enabled. This can be done by adding -C to the bluetoothd line in /etc/systemd/system/dbus-org.bluez.service

The Festival speech synthesiser is used to make announcements, installed as described on this page.


Create a directory named /home/pi/boot and copy the three Python scripts into it. If the scripts are installed to a different directory, the file paths within the scripts should be modified accordingly.

Call at boot time, for example by adding this line to cron with sudo crontab -e

@reboot python /home/pi/boot/ >/home/pi/boot/bootscript-bt.log 2>/home/pi/boot/bootscript-bt.err


The script starts the robot Bluetooth server and the shutdown monitor. This script is optional, but may be useful for headless operation.

The script waits for a button to be pressed, then halts the Raspberry Pi. This script is optional, but may be useful for headless operation.

The Bluetooth server script initialises the Raspberry Pi hardware, then starts a Bluetooth serial port service to listen for commands to control the robot from a connected device. The server returns robot status information (from the LEDs, ultrasound unit and line follower unit) encoded in JSON format.

The script may need to be adapted depending on how the hardware components are connected; in particular, when using EduKit 1 and EduKit 3 simultaneously, it is necessary to use different GPIO pins for EduKit 1 than are shown in the CamJam worksheets.

The script first flashes the LEDs, then illuminates the yellow LED while waiting for a Bluetooth client to connect.

The green LED is illuminated when a Bluetooth connection is initiated by the client Android device, and the server is ready to accept commands. The supported commands can be seen by inspecting the script.

The red LED is illuminated whenever the motors are active. The yellow LED is illuminated, accompanied by an audible warning from the buzzer, when an object is detected within 10 cm of the ultrasound unit.

Android App

The roboclient_bt.apk file is a packaged Android app that should run successfully on any recent Android device equipped with Bluetooth. ‘Sideloading’ of apps needs to be enabled in order to install the client app. On most devices there is a checkbox under Settings -> Security that refers to installing apps from unknown or untrusted sources. Some devices will prompt the user to change the setting when an attempt is first made to sideload an app.

The Android device must be paired with the Raspberry Pi before starting the app for the first time. This can be done by making the Android device discoverable and then using bluetoothctl on the Raspberry Pi:

pi@raspberrypi:~ $ bluetoothctl
[NEW] Controller AA:AA:AA:AA:AA:AA raspberrypi [default]
[NEW] Device BB:BB:BB:BB:BB:BB Nexus 7
[bluetooth]# pair BB:BB:BB:BB:BB:BB
Attempting to pair with BB:BB:BB:BB:BB:BB
[CHG] Device BB:BB:BB:BB:BB:BB Paired: yes
Pairing successful
[bluetooth]# exit
pi@raspberrypi:~ $

Alternatively, make the Raspberry Pi discoverable, and initiate pairing from the Android device:

sudo hciconfig hci0 piscan

Start the app and click the Connect button to establish a Bluetooth connection with the Raspberry Pi. On successful connection, the status message on the app changes to show the distance detected by the ultrasound module.

Sliding the Raspberry Pi icon around on the blue canvas controls the motors, and affords full control of speed and direction. The robot stops automatically when the icon is released. The slider below the canvas controls the maximum motor speed.

The buttons at the bottom sound the buzzer, speak a preset phrase, and flash the LEDs.  

MIT App Inventor

The roboclient_bt.aia file contains the MIT App Inventor source from which the app is built. This file is not required to use the app.

MIT App Inventor allows Android apps to be easily built using drag-and-drop interfaces for both design and coding. Further information is available at:

Once an account has been created on App Inventor, roboclient_bt.aia can be imported as a new project in order to examine and modify the code. The app can then be rebuilt and downloaded locally as an APK file, or installed directly to the Android device via a QR code.

Gerard Kelly, November 2016


Raspberry Pi Robot - Android Remote Control (Bluetooth)







No releases published


No packages published