Arduino + Bluesmirf

Hi all,

I'm rather new to Serial Programming. I was trying to get the Arduino Uno with a Bluesmirf Gold from Sparkfun to connect to my cell phone (1st Generation Moto Droid.) I wanted it to be in autoconnect mode so that was SM,3 and I tried to preset the address to my phone's.

I tried reading the command list from the data sheet and I've attached my basic code.
After pairing with the Firefly (thats the device name?) from my phone, my code does not seem to make the Bluesmirf initialize a connection with my phone. Another interesting problem is that when i send "L" in a loop, the TX-light on the Arduino runs constantly as it should. However, thinking that the USB serial was confusing the Arduino, upon running off external power, the TX-light turns off - even upon reset. Then when I put back the USB, the TX-light stays off until another reupload.

Here's my code:
void setup() {
Serial.begin(115600);
}

void loop() {
Serial.println("$$$"); //I tried print() as well - not sure if I need the newline
Serial.println("SR,0024BA921ACF");
Serial.println("SM,3");
while(Serial.available() == 0)
{
Serial.print("L");
}
}

As an additional note, I connected RTS-0 with CTS-1 (though I'm unsure what that really does, I saw them on some other examples)

If you guys could help me set up this connection and let me know what I'm doing wrong - I would really appreciate it.

Thanks,
itsWezzles

I have seen a lot of problems with these in the past few days and after many many hours i have finally figured out how to configure the bluesmirf (gold) with the arduino uno. Here is the step by step:

  1. First check the baud rate of you're bluesmirf. This is done by connecting the arduino to your computer via USB cable. Put a wire from Vcc to the 3.3 V pin on the arduino for power and connect another from gnd to gnd on the arduino for your ground. Make sure both of these are firmly connected. This should cause the red light on the bluesmirf to start blinking to show that it is on. Next take a volt meter and connect the ground lead to another available ground on the arduino. Use the voltage lead to check pin 4 (PIO7) on the RN41 chip (The main IC bluetooth radio chip). If this pin is high (3.3V) the bluesmirf will have a baud rate of 9600 if not it will most likely be 115200.

  2. Next go to this website: http://www.arduino.cc/en/Tutorial/SoftwareSerial . The full code you will need is located at the bottom of the page. Some of the information in the tutorial preceding the code is incorrect, however the code does work. Copy and paste it into the arduino programming software, compile and upload it to the arduino board without changing anything. Starting serail on the arduino automatically assumes the RX and TX pins will be used. This will allow you to communicate with the bluesmirf through the arduino via it's USB connection. Despite what the tutorial says hook up RX on the bluesmirf to RX (pin 0 on the uno) and hook up TX to TX (pin 1 on the uno) with a wire. Make sure the connection is secure. THIS IS NOT A TYPO HOOK UP RX TO RX AND TX TO TX. This is the only way it worked for me, if you go through the rest of the steps and it doesn't work than switch them, however unless my bluesmirf or arduino is improperly labeled leave them as i suggested. This leaves the CTS and RTS pins. Use a jumper wire to securely connect these to each other.

  3. Close the arduino software program but leave the board connected to your computer. Next go to this web site: http://www.hilgraeve.com/hyperterminal/ , and download the software for your computer. It has a free 30 day trial once you download it.

  4. Start the software and name the connection bluesmirf or whatever you feel like and click ok. The next pop-up will be the "Connect To" menu. From here select the same communications port that the arduino uses. For me it was "Com 6". Next hit the "Configure" button and where it says "Bits per second" select the baud rate you found earlier, and press ok until it brings you to the white command screen.

  5. From here select "File"->"Properties". It should bring up the same "Connect to" tab you saw a second ago. This time however there will be a "settings" tab also. Click on that tab and where it says "emulation" change it from "auto detect" to "ANSIW" and click the "ASCII Setup..." button towards the bottom of the tab. On this screen check "Echo typed characters locally" and "Append line feeds to incoming line ends" leaving everything else the same. Once checked click ok a bunch of times till you get back to the white screen.

  6. You only have 60 seconds from start up to enter command mode on the bluesmirf module so disconnect the 3.3 V wire from the arduino board for a few seconds, plug it back in. The red light on the bluesmirf will blink more rapidly than it was before. Go to the Hyper Terminal command screen and type "$$$" before the light stops blinking quickly and press enter. You should see "CMD" on the screen returned by the bluesmirf module letting you know it is in command mode. The red LED will also blink much more rapidly.

  7. From here you can more easily enter commands and get feedback from the bluesmirf module. This site contains a list of commands: http://www.sparkfun.com/datasheets/Wireless/Bluetooth/rn-bluetooth-um.pdf . Page 23 shows how to connect to a device. This is as far as i have gotten. I have not been able to connect to my DROID X, however I will post that information when i figure it out.

If you get an error when trying to load the arduino program to the board that says "AVRDUDE: bla bla bla" this means that there are wires in the TX and RX connections on the arduino board. Simply disconnect them to load the program. If "$$$" does not return "CMD" you have probably selected the wrong baud rate. I changed the baud rate to 9600 from 115200 and started a new connection with Hypertermanal for programming the bluesmirf and this worked fine for me.

Wow, that was very detailed and seems like it took a lot of time.
I will definitely check out all that you said.

I must say TX-TX and RX-RX seems odd but I will give it a go.

My project was supposed to be controlling the BlueSmirf using the Uno to send the serial commands and not the hyperterminal from the computer. Do you know anything about this?

I was looking at using the "L" command to process a strength indicator functionality on the microcontroller.

About connecting to your DroidX, I heard somewhere that it doesn't support such connections (I forgot off what information they made this claim) but I just remember reading something about the MotoDroid (only 1 was out at the time) being one of the few Droids able to make such connections.

Let me know if you make any progress or if you know anything about instructing the Bluesmirf via the Uno.

You can use the Serial program I posted to communicate using the serial monitor in the arduino software itself. I was only able to enter command mode, however i could not send commands outside of that. I'm honestly somewhat clueless when it comes to the intricacies of serial communication, however if you need to control the Bluetooth module directly with an arduino sketch i would recommend using an oscilloscope on the RX and TX lines to record the communication between the computer and the bluesmirf and then write a sketch using the arduino to emmulate the communication you observed. I know that's kind of a questionable way of doing it if you get a grade for your project, but i cannot really think of another way with what i've seen so far. The other problem is that i have seen many comments regarding the bluesmirf not actually being set to the defaults that the datasheet says. You may have already figured out to do it, but the bluesmirf is in the wrong mode. Try configuring the module using the "SM,<0,1,2,3,4> commands first to set it to slave or master or whatever it should be then try running the program again.

This just in: The S2 Bluetooth app available in the android market as a free download allows for connection with smartphones!