Starting with Raspberry Pi Bluetooth & Python

I recently started doing a small fun project with a RPi and a BT enable remote controlled car. (Dagu Racer 1) when I hit some problems with writing Python code to connect to the RPi’s BT.

After some web browsing and a bit of trial and error I found the following application updates and library installs got things working.


sudo apt-get update
sudo apt-get install bluetooth bluez libbluetooth-dev
sudo python3 -m pip install pybluez

For the Python code


import bluetooth

# Bluetooth stuff
bd_addr = “20:13:05:30:01:14”
port = 1
sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM )
sock.connect((bd_addr, port))

# 0x1X for straight forward and 0x11 for very slow to 0x1F for fastest
sock.send(‘\x1A’)

One Response to Starting with Raspberry Pi Bluetooth & Python

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: