SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By willum070
#174005
UPDATE: I have resolved the issue, it was due to the baud rate being set incorrectly on the BlueSmirf. To compound matters I neglected to reset the Arduino after initially changing the baud rate, so it did not appear to have an effect. I unplugged the battery, and then the next morning when I tried it again it worked! So the moral of the story is, make sure your BT transceiver baud rate is set to the same value used by your software (9600 in my case), and if you change any properties on the BT transceiver (the ones that require command mode), be sure to reset your Arduino so that the changes take effect.

Hi all, I am working with a BlueSmirf RN41-1 connected to an Arduino Uno. I was able to successfully pair the unit with my laptop, and I can enter command mode just fine. However I can't get it to work in my programs. I first attempted to get it to work with https://labofthings.codeplex.com/, and although I was able to get the Arduino to work using a standard USB serial connection, I found that it timed out on read operations when connected to the Bluetooth port. So I wrote a very simple C# console app (code below), and was able to confirm that it in fact times out when ReadTo() is called. The sketch code is here. Here is the C# console app code:
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.IO.Ports;

namespace cereal
{
    class Program
    {
        static void Main(string[] args)
        {

            SerialPort sp = new SerialPort("COM8", 9600, Parity.None, 8, StopBits.One);

            // Should we try using an event handler instead?

            try
            {
                if (sp.IsOpen == true) sp.Close();
                sp.Open();

                Console.WriteLine("Port opened.");                

                sp.ReadTimeout = 20000;
                
                sp.Write("[?]");
                //Thread.Sleep(20000);
                string rawData = sp.ReadTo("]"); //TimeoutException happens when using a bluetooth serial port.
                Console.WriteLine(rawData);

                Console.WriteLine("Press enter to exit.");
                string line = Console.ReadLine();                
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadLine();
            }

        }
    }
}
When I issue the [?] command using the serial monitor it returns "àààààààààààààààààààààààààààààààààààààààààààà" (is that a cry for help?)

One more note, BlueSmirf is connected via D0 and D1 (using Sparkfun protoshield).

Any ideas?