# How can I create a serial bridge using two Bluetooth dongles?

I own two of the SparkFun BlueSmirf bluetooth modules and I would like to connect them to eachother - one as the master, and one as the slave. It is easy to pair these together using a PC with Putty as the master, but some of the commands for the module require a carriage return to send a command.

How can I pair these bluetooth modules between two Arduinos without using a PC to send the carriage command signal from putty while the device is being configured?

I have thoroughly looked over the datasheet and command sheet for the module itself, but it does not include information of how to get past this problem.

• Have you tried sending a \n, \n\r or \r\n through a Serial.print()? Depending on the protocol used, some serial devices require a carriage return, a linefeed, or a CR-LF pair, as an End-of-Line delimiter. – Anindo Ghosh Apr 10 '13 at 8:15
• Unfortunately, I have tried all of those, but they are not the same as pressing enter. – Sponge Bob Apr 10 '13 at 16:14
• @KeeganMcCarthy Then you need to determine what PuTTY is sending down the line when you hit enter. This is almost always \r\n or something similar but it should be available in the settings. – Kevin Mark Apr 10 '13 at 18:55

I explain the way to do it on this blog post or in great details on this Instructables. For now, here is the basic code that you can put on the master device and the slave device.

//Master code
void setup() {
Serial.begin(115200);
Serial.print("$$"); delay(100); Serial.println("SM,1"); delay(100); Serial.println("C,000666123ABC"); delay(100); Serial.println("---"); } //Slave code void setup() { Serial.begin(115200); Serial.print("$$$"); delay(100); Serial.println("SM,0"); delay(100); Serial.println("---"); } And some tips before you go further with Bluesmirf: 1. Read the User Manual 2. Serial speed: By default, BlueSmirf is set to 115200 so you need to call Serial.begin(115200); before sending the first command. 3. The "$$" command is the only one that is not followed by a carriage return. Why? To complicate things of course. Use print() for the "$$$" command and println() for all other commands.
4. Read and validate all the responses that are sent back.
5. Wait 100ms delay after each command you send and before trying to read the response. This will give Bluesmirf the time to process the command.
6. Don't forget to exit the command mode (using “---”). Some commands are not effective until you have exited the command mode (e.g. MS command).

You can send a carriage return through the Serial by doing something like this:

Serial.print("\r");

You can also include the command (or whatever you're sending) and the carriage return in the same print string like this:

Serial.print("Everybody Dance Now\r");

• unfortunately sending "\r" is not the same as pressing enter when using PuTTY. – Sponge Bob Apr 10 '13 at 6:23
• @KeeganMcCarthy Then pressing enter must be more than sending a carriage return. Try \r\n – Kevin Mark Apr 10 '13 at 18:53

Bluetooth uses a host and device model. A device requires a host to communicate.

The modules you are using are devices while your PC is a host.

It is not possible for two Bluetooth devices, with the serial port profile (SPP), to pair with each other. They can only pair to a host.

• I have actually paired them together. But I use a USB-UART chip to initialize the connection between them. – Sponge Bob Apr 10 '13 at 16:13