Improving latency of HC-05 bluetooth module

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I need to send the raw data from an accelerometer to my computer. I am reading the accelerometer's data with the atmega328P (the whole circuit is at 3.3V). I am then sending that info via UART to the HC-05 bluetooth module with a baud rate of 9600 (The atmega328 has a crystal of 16MHz). I need to constantly send that data, but I am noticing that there is a delay between each transmission. It's a really bad latency, I haven't measured it but it might be around 0.3-0.5 seconds. How can I improve that? Would changing the baud rate to a higher one help (e.g 115200)?

I have been using the WT12 bluetooth module for a while, but recently it stopped working for no reason. And the HC-05 seems to be a better option because of its low price. But I really need to send data constantly, and eliminate most of the delay.

How can I do that with the HC05?

Thanks in advance.

Last Edited: Fri. Oct 16, 2015 - 02:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The HC-05 should work seamlessly.
Note that it takes a couple of seconds to start the initial link.

I might have a HC-05 or HC-07 on an AVR or ARM board.
When I 'open' the PC terminal to COM34 or COM35, there is a noticeable time when the red light is flashing. Once validated, the red light is steady.

From then on, you might just have a wired link. The BlueTooth is rock-solid!

I suspect that your PC is breaking the BT link. Which Terminal Software are you using?

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
The HC-05 should work seamlessly.
Note that it takes a couple of seconds to start the initial link.

I might have a HC-05 or HC-07 on an AVR or ARM board.
When I 'open' the PC terminal to COM34 or COM35, there is a noticeable time when the red light is flashing. Once validated, the red light is steady.

From then on, you might just have a wired link. The BlueTooth is rock-solid!

I suspect that your PC is breaking the BT link. Which Terminal Software are you using?

David.

Hi David,

That's really good to hear that the HC-05 should work just fine for my application, but at the same time it makes me wonder what the heck is going on with my BT connection. :?

Well, because of drivers' issues with my rocketfish bluetooth dongle, I haven't been able to make it work on Windows yet. So I am using Ubuntu, and using Minicom as my terminal emulator. The data I get on the terminal is very laggy (I even tried to read the serial port, rfcomm0, directly from a python script, which has the same result or maybe worse...).

I also noticed that the link quality of by BT conection is really low. Even though the HC-05 is just like 1 foot away from my bluetooth dongle.

I have attached a screenshot on this that shows my bluetooth connection on Ubuntu (notice that low link quality), and you can even see part of the code that I am using on the Atmega. The red LED on the HC-05 has this pattern when it has paired: "blink blink........blink blink........blink blink", I am not seeing the steady light from the LED you mentioned...

What am I doing wrong?

Here is the screenshot if you can't see this message's attachment: http://intelsath.com/screenshoth...

P.S After a while (about 30 minutes), the terminal doesn't give anything else, no new incoming data is shown... But the HC-05 is still paired to the computer, and the LED is blinking just like it was when there was incoming data shown in the terminal emulator.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quick question...I am sending the data from the MCU to the HC-05 like if I was sending it to the serial port of my computer... Do I have to do something different if I send it to the HC-05? Like do I have to enter the AT mode everytime I want to pair with my computer? I am just assuming I can use all the default settings and just start sending all the data from the atmega to the HC-05 right away.

I am new to working with Bluetooth technology, so I don't have much experience so please bear with me. Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just tried the two Bluetooth modules on Ubuntu 10.04

It let me set up the first moule as /dev/rfcomm0 but would not accept the second module for /dev/rfcomm1

Anyway, apart from the 1-2 second "connect" time, it was happy with continuous 9600 baud TX.

No, you don't need any AT commands unless you want to change the default baudrate. You can put "bind yes;" in the /etc/bluetooth/rfcomm.conf

So your BT module should always be available from boot-up.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
I just tried the two Bluetooth modules on Ubuntu 10.04

It let me set up the first moule as /dev/rfcomm0 but would not accept the second module for /dev/rfcomm1

Anyway, apart from the 1-2 second "connect" time, it was happy with continuous 9600 baud TX.

No, you don't need any AT commands unless you want to change the default baudrate. You can put "bind yes;" in the /etc/bluetooth/rfcomm.conf

So your BT module should always be available from boot-up.

David.

Hey David, thank you so much for trying it out. And thanks for the suggestion, I just edited the rfcomm.conf file!

Should I worry about my link quality of 10%? I am suspecting that that has something to do with the issues I am experimenting.

I think I'll try with a higher baud rate and see if that at least improves my data.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I started Ubuntu this morning with the 'bind yes' in the rfcomm.conf
It did not work. Perhaps rfcomm.conf was not read at startup !
So I had to 'sudo rfcomm bind rfcomm0' by hand instead.
Then I could use a Terminal with /dev/rfcomm0

rfcomm1 still does not work.

How do you see a "link quality of 10%" ?
I have only used 'sudo rfcomm' command.

Incidentally, when I rebooted as Windoze-Vista32, both Bluetooth devices had paired but I could not use them as COM46, COM47. (i.e. visible but would not connect')
After a considerable panic, I just removed each 'Wireless Device'. Then used 'Add Wireless Device' to re-install them. Hey Presto, both COM46 and COM47 are usable again.

Regarding your latency. If you have a steady red light, you are 'connected'. If you have an appalling RF signal, the link may need to re-transmit packets until success. e.g. slow throughput.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
I started Ubuntu this morning with the 'bind yes' in the rfcomm.conf
It did not work. Perhaps rfcomm.conf was not read at startup !
So I had to 'sudo rfcomm bind rfcomm0' by hand instead.
Then I could use a Terminal with /dev/rfcomm0

rfcomm1 still does not work.

How do you see a "link quality of 10%" ?
I have only used 'sudo rfcomm' command.

Incidentally, when I rebooted as Windoze-Vista32, both Bluetooth devices had paired but I could not use them as COM46, COM47. (i.e. visible but would not connect')
After a considerable panic, I just removed each 'Wireless Device'. Then used 'Add Wireless Device' to re-install them. Hey Presto, both COM46 and COM47 are usable again.

Regarding your latency. If you have a steady red light, you are 'connected'. If you have an appalling RF signal, the link may need to re-transmit packets until success. e.g. slow throughput.

David.

David,

I finally got it working. After trying your suggestions and everything else I could think of (like increasing the baud rate) and seeing that nothing worked, I just gave up and decided to buy another bluetooth dongle for my computer. Apparently the bluetooth dongle I had did not work properly, and now I can send all that continuous data without a problem! No delay at all. And all I had to do was change the bluetooth adaptor... It's weird because it was working just fine with the WT12 I had, and it just coincidentally stopped working when I decided to use the HC-05.

Thanks a lot for your help! I really appreciate it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have only got a HC-06 and a HC-07 board. Both of these are Slave-Only. However, this is all that I want to communicate with a PC terminal.

The HC-05 is a lot more sophisticated. It can be Master or Slave. It responds to many Hayes AT commands.

If you want it to change from its default, you need to talk to it in AT commands. It should behave just as well when Slave as any HC-06 or HC-07.

I have ordered a HC-05 to try for myself. I will then be able to be justify my (untested) assertions. Not only that, but I can be Master too.

David.