Autonomy via Bluetooth

Bernat Romagosa edited this page Feb 28, 2018 · 1 revision

This guide has been translated and adapted from Víctor Casado's HOWTO (in Catalan), and it describes how to use an HC-06 Bluetooth module to substitute the USB cable. These are cheap and reasonably easy to set up, and you only need to configure each module once.

Setting up the module


First of all, you need to connect the module to an Arduino board by following the schematics below:

HC-06 and Arduino - Schematics

Serial Sketch

The next step is to use the Arduino IDE to push a simple program to your board that will allow us to configure the module:

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // TX | RX

void setup()
  Serial.println("Enter AT commands:");
  BTSerial.begin(9600);  // Bluetooth serial port data rate (change if needed)

void loop()
  // Keep reading from HC-06 and send to Arduino Serial Monitor
  if (BTSerial.available())

  // Keep reading from Arduino Serial Monitor and send to HC-06
  if (Serial.available())

Serial Monitor

We can now open the serial monitor from the Arduino IDE by either pressing Control+Shift+M or by choosing the Serial Monitor option from the Tools menu.

In the serial monitor window, you need to make sure that the baud rate is set at 9600 baud and the option No line ending is selected, just like in the image below:

Serial Monitor Options

Enter the command AT in the text input box at the top, and either press the Enter key or click on Send. You should receive the word OK back from the board, informing you that the module is ready to receive your commands. If this is not the case, please make sure the baud rate is properly set up, the module is connected as shown in the schematics, and the program has been properly pushed to the board.

Module Configuration

You just need to give the module a name and configure it to the baud rate at which it should communicate with Snap4Arduino.

Naming the Module

This step lets us set the name that will show up when you scan for the Bluetooth module. It is specially important to perform this step if we plan to use several boards with different modules at the same time.

To set its name to WHATEVER you just need to send it the following command:


If all goes well, the module should respond with OKsetname.

Setting the Module Baud Rate

We now need to set up the speed at which the module and Snap4Arduino should communicate with each other.

Snap4Arduino requires a baud rate of 57600, and the AT command that sets the module to this speed is:


To which the module should respond with OK57600.


Rewiring the Module

Now that the module is set up, we need to rewire it so that it can act as a serial bridge for the board. Doing so is as simple as connecting the module's TX pin into pin 0 in the Arduino, and the module's RX pin into the Arduino's 1.

Uploading StandardFirmata

We can now upload StadardFirmata to the board by following the usual procedure.


As with any other Bluetooth device, we need to pair our computer to the module. How to do so depends on your operating system, but these are the common steps you need to follow:

  • Search: You first need to find the module by the name you have given to it in the [Naming the Module](Naming the Module) step.
  • Pairing: When pairing with the module, you will be asked for a password. The default one is 1234.
  • Connection: If you are using Microsoft Windows or MacOSX, you will also need to connect to the module after pairing. If you are using GNU/Linux do not connect to the module yet.

MacOSX and Microsoft Windows Specific Instructions

In case you are using either of these operating systems, you can now open Snap4Arduino and click on the Connect Arduino button. In MacOSX, the Bluetooth port should contain something similar to DevB, whereas in Microsoft Windows you will have to guess the COM port that corresponds to it, usually the last one.

You're all set! :)

GNU/Linux Specific Instructions

In case you are using GNU/Linux, you will need to perform a bunch of additional steps.

First of all, you need to find out the module's MAC address. You can either find it out by using your particular GNU/Linux Bluetooth widget (usually located in the system status bar), or by issuing this command in a terminal:

hcitool scan

Once you have the MAC address, you need to bind the device to a virtual serial port in your file system by running:

sudo rfcomm bind /dev/rfcomm0 MAC-ADDRESS

Or course changing MAC-ADDRESS by your module's MAC address.

In Snap4Arduino, you will need to use the custom connection block, as the newly created rfcomm0 device will not show up in the available port list:

Connection block in GNU/Linux

You're all set! :)