Raspberry Pi Robot controlled over Bluetooth

This tutorial is based on a previous Instructable ‚Äď

Building robots with Raspberry Pi and Python

The aim is to present an example of how to setup a Bluetooth serial connection with Arduino to control a Raspberry Pi robot. But lets take it one step further and add Python to generate sounds based on the commands sent over Bluetooth. So basically we are going to send messages from a Android App over Bluetooth to a Arduino, then relay the messages from Arduino (USB) to the Raspberry PI where Python will play sounds based on those messages. So one example would be to send the robot a command like move forward and have it play some cool robot noises from the Raspberry PI. So lets get started…

Step 1: Parts list

 We are going to use the same parts from this previous tutorial for the robot base. ( Robot base, Raspberry Pi, Arduino Uno, motor driver, battery, etc )


And we are going to add the following parts to the list.

Bluetooth modem                    http://www.zagrosrobotics.com/shop/item.aspx?itemid=883

Speaker                                      Some type of powered speaker with a 3.5 speaker jackRaspberry Pi Robot controlled over Bluetooth

Step 2: Python installation and robot base setup

Older versions of the Raspbian image have had issues with sound output to the 3.5 speaker jack so it is recommended to install the Noobs v1.2.1 image or later.


There is alot of information on setting up and configuring your Raspbian image here

Python is pre-installed, but we can check our Python version by using the terminal to verify.

Copy and paste in the LXterm

python ‚Äďversion

For the examples we are going to go over it is recommended that you use Python version 2.6.

***If Python is not installed on your system you can use apt-get granted your Raspberry Pi is connected to the Internet.***

Copy and paste in the LXterm

sudo apt-get install python2.6

Also for the examples in this tutorial we need to install some of the the dependent libraries for our scripts to work.

Copy paste in the LXterm

sudo apt-get install python-serial

Also you may or may not have to set the Raspberry Pi’s output to the 3.5 audio jack with the command line

Copy paste in the LXterm

amixer cset numid=3 1

Next download the Sound files below then add a folder labeled Sounds to ‚ÄĚ /home/pi ‚ÄĚ and add the .wav files to it (Ex. /home/pi/Sounds/forward.wav )

Sound files

Next download and add the following Python script to ‚ÄĚ /home/pi ‚ÄĚ


Now we have to make the python script executable with a chmod command

Copy and paste in LXterm
sudo chmod +x /home/pi/zagbot-bt.py
The program should now be executable. Next download and upload the following sketch with the Arduino IDE 1.0.4 or above to you Arduino Uno.
Arduino Robot Base Sketch
If you are unfamiliar with Arduino and its IDE you can read up on it here.
And lastly refer to the wiring diagram above for setting up the power connections to the robot base.Raspberry Pi Robot controlled over Bluetooth schematic

Step 3: Arduino and Bluetooth Wiring

After you have assembled your robot base, the next step is to wire up your Arduino Uno to the Bluetooth Silvermate. Since we are going to be using the USB port to receive data. We are going to use the software serial library to add another serial line to the Arduino Uno to receive the Bluetooth data. Here is the wiring diagram.
*If your Bluetooth module is different than the one I have suggested refer to documentation, or data sheets that are associated with your Bluetooth module to properly install it.*
Arduino PIN¬†¬†¬†¬† (TX)2 ¬† ¬†‚ÄĒ¬†¬†¬† Silvermate¬†¬†¬† RX
Arduino PIN¬†¬†¬†¬† (RX)3 ¬† ‚ÄĒ¬†¬†¬† Silvermate¬†¬†¬† TX
Arduino PIN¬†¬†¬†¬†¬†¬†¬†¬†¬† 5V¬†¬†¬† ‚ÄĒ¬†¬†¬† Silvernate VCC
Arduino PIN¬†¬†¬†¬†¬†¬† GND¬†¬† ‚ÄĒ¬†¬†¬† Silvernate GND
Silvermate¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† CTS¬†¬† ‚ÄĒ¬†¬†¬† Silvermate¬† RTS

Step 4: Android App

Here is a basic Android app that sends string commands via bluetooth to our Arduino Uno. Of coarse you can always write you own .apk to Incorporate a more advanced interface using your phones accelerometer, or touchscreen using sliders for motor speed and direction. Transfer the .apk to the sd card on your phone or tablet and use an app like ES file explorer to gain access into the SD card and install the .apk.

ES FIle Tutorial ¬† ¬†‚ÄĒ ¬† ¬† ¬†http://www.youtube.com/watch?v=myOW8YrcSzg

Max_Control App ‚ÄĒ¬†¬†¬†¬† https://www.box.com/s/8b06bcee9ec84ec70a72



For more detail: Raspberry Pi Robot controlled over Bluetooth

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top