title: Baud rates for stable Bluetooth serial communication
body: <p>I have an Arduino mega communicating over Bluetooth (bluesmirf gold device) to a C# application that I wrote. The Arduino is constantly sending a serial signal of 32 characters, the first always being an &quot;S&quot; and the last an &quot;E&quot;. Using putty I can confirm that this signal is being sent correctly 99% of the time.</p>
  <p>Now I want to read this signal with my C# application, which I am doing with the following code:</p>
  <pre><code>    public string receiveCommandHC()
      {
          
          string messageHC = &quot;&quot;;
          if (serialHC.IsOpen)
          {
  
              while (serialHC.ReadChar() != 'S')
              {
  
              }
              messageHC = serialHC.ReadTo(&quot;E&quot;);
              serialHC.DiscardInBuffer();
          }
          return messageHC;
           
      }
  </code></pre>
  <p>serialHC is of the serial class.</p>
  <p>Sometimes this works perfectly but other times I'm having problems, I cannot find out why it works sometimes but others not.</p>
  <p>The problem that I seem to be having is that sometimes I get a rather large Lag in the data that I am reading from the arduino. I notice this because I am sending button states and they only change a few seconds after I actually press or release the button on the Arduino. I used the standard baud rate of the Bluetooth device, which is 115200, and was wondering if changing that to a much lower rate could yield better results? What if any advantage would that have? I do not need hight communication rates, even updating the state 4-5 times a second would be acceptable for my application.</p>
  <p>Is it possible the lag is coming from my code? I think it may be from the while loop that is waiting for the incoming &quot;S&quot; but then I don't see why it should hang there since there are new signals always coming in at a high rate.</p>
  <p>I'm using the DiscardInBuffer() because I do not care about outdated data and just want to skip over that. It is much more important that I am reading current up to date data and acting on that fresh data.</p>
  <p>Thank you for your help!</p>
  <p>Best regards,</p>
  <p>Bender</p>
  <p>Update:</p>
  <p>Just found out a bit more information while debugging. The problem only seems to appear:</p>
  <ol>
  <li>When connected over Bluetooth (over USB cable there is absolutely NO Lag)</li>
  <li>When a second Bluetooth connection is established from the PC to another device (different COM port and different baud rate)</li>
  </ol>
  <p>Does anybody have any experience running two different devices off the same Bluetooth dongle on the PC? I can manage to connect to both no problem but still having the lag issue mentioned before.</p>
  <p>Thanks for any help</p>