Control robot via serial port

Connect computer to bluetooth-to-UART module

1. Connect bluetooth-to-UART module power line (e.g. to Arduino board) – a module without 5v-to-3.3V DC-regulator need to be connected to an Arduino board pin +3.3V and GND; module with DC-regulator can be connected to +5V and GND.

2. Shorten pins RX and TX of the module by a wire – data from the pin TX will be sent to pin RX of the same module

Bluetooth2UARTAdapter41C6ShortenedTXRX Bluetooth2UARTAdapterCSR41C6WithLevelConverterShortenedTXRX

3. Start the Terminal (hit Ctrl+Alt+T)


4. Search for a bluetooth adapters build-in in the computer or connected over USB

hcitool dev


The command found only one bluetooth adapter with MAC 08:ED:B9:F7:3C:66. Its current id in the system “hci0” can be used in other commands.

hint 'hcitool' utility

“hcitool” is a utility for configuration of Bluetooth connections and devices.

When more adapters connected to the computer the result can be following (where there is one adapter build-in in the computer and two USB dongles connected to it)


MAC address can be found on bottom side of the laptop and on the USB dongle


 5. Search for bluetooth devices available around

hcitool scan


The device found in this example is bluetooth module connected to an Arduino board. Its MAC address required for other commands. It works in “slave”-mode and can be connected to computer’s bluetooth device or USB dongle.

hint BlueZ - an official bluetooth protocol stack

Currently Linux has BlueZ as an official bluetooth protocol stack included with the official Linux kernel distributions. BlueZ also contains the bluez-utils and bluez-firmware packages containing utilities.

BlueZ can be installed by the command

sudo apt-get install bluez python-gobject python-dbus

“python-gobject” and “python-dbus” are needed to run Python scripts (e.g. “bluez-simple-agent” and “bluez-test-device”)

 6. Pair found bluetooth module. This one time operation usually requires to enter PIN code on pairing device. There are well known pin codes like “0000”, “1111”, “1234”, etc. For this particular module it is “1234”, its MAC is “00:11:12:22:04:77”, it is paired with the build-in laptop bluetooth device with id “hci0”. The script “bluez-simple-agent” prompts for PIN to be manually entered

bluez-simple-agent hci0 00:11:12:22:04:77


hint Restart a bluetooth service

Following command restarts the bluetooth service on the computer

sudo service bluetooth restart


Bluetooth module can be paired with more than one bluetooth device connected to the computer


If a device is already paired – an error is shown


hint Look for paired devices and unpair devices

Script “bluez-test-device” with an argument “list” displays paired devices

bluez-test-device list


Script “bluez-test-device” with an argument “remove” and MAC address unpaired a device

bluez-test-device remove 00:11:12:22:04:77

7. Connect to the bluetooth module with “rfcomm”

sudo rfcomm connect rfcomm0 00:11:12:22:04:77


hint Bluetooth protocol 'RFCOMM'

RFCOMM (“Radio frequency communication”) – set of transport protocols, also known as “serial port emulation”. RFCOMM provides a simple reliable data stream.

This command connects the bluetooth-to-UART adapter to a device “/dev/rfcomm0”. device can be defined in the command as a number – “0” is “/dev/rfcomm0”, “1” is “/dev/rfcomm1”, etc

sudo rfcomm connect 0 00:11:12:22:04:77

sudo rfcomm connect /dev/rfcomm0 00:11:12:22:04:77

hint Channel used by connection with 'RFCOMM'

Command “rfcomm” has an optional argument “channel” – when it is not specified the channel 1 is used. Some of channels can be already used – following command displays used resources

sdptool browse local


More quick overview of used channels can be found with command “grep”

sdptool browse local | grep Channel


 8. Start “CuteCom” and open the device with name “/dev/rfcomm0” – enter the device name in the field “Device” and click on the button “Open device”. Because RX and TX pins of the bluetooth-to-UART are shortened any sending text will we received back and displayed in the output field