B4R Question HC-06, What baud rate ?

D

Deleted member 103

Guest
Hi,

I use as a Bluetooth module a HC-06 with 9600 baud rate.
The communication with my app actually works properly, only in rare cases, if the Bluetooth device is installed in some oldtimer car, the communication is disturbed.
I wonder if the communication improves if one Baud setting is listening, for example to 57600 baud rate, whether it becomes better or not.

Or does the baud rate have nothing to do with it?
 
D

Deleted member 103

Guest
I think I have asked the question wrong. :(

How to change the baud rate is known to me,
The question is whether with higher baud rate the transmission is more stable.
 
Upvote 0
D

Deleted member 103

Guest
My guess is that it won't be more stable.
Too bad, :(
but still thank you. :)
Then I have to intercept the interferences electronically, as, I do not know yet, but some solution is there somewhere.
 
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
what do you mean?
When one controller communicates with another one the baud rates have to match within a few percent. Some combinations are very bad, other even at much higher values might be better or even perfect. (I never use low buad rates, best works for me at 921600 or so from AVR (using ATXMEGA) to HC05). The communication consists of a series of pulses with certain frequency that depends on the controller baud rate as being set and CPU's running frequency. Both seldom fit perfectly. Assuming your HC baud rate exactly is as stated (also is matter of chance) you can choose a good combination of baud rate and frequency of your controller. Sometimes I have to change the running frequency of the CPU in small steps to watch the transmission. I print the Crystal frequency (stepped in small steps) and see when the text becomes readable at a certain frequency.
I did not use B4R or Arduino for those projects (Bascom compiler), you have to be able to change the oscillator frequency by "oscal" command, so I don't have an example at hand, but in Arduino-world that should exist.
Here is some calculator, there are lot of others.
Unless you use a good combination of those two quantities you will not have a stable communication.
http://wormfood.net/avrbaudcalc.php
Just digged out this example for Attiny841 (Osccal0 is specific for that controller)
B4X:
Zero = Osccal0
For count= Zero To 200 Step 2 : Osccal0 = count: print #1,count: Next
 
Last edited:
Upvote 0
D

Deleted member 103

Guest
Unless you use a good combination of those two quantities you will not have a stable communication.
The problem is that it is used by different devices with different CPU, and then I can not set different Baudrate.
Or can you?
 
Upvote 0
D

Deleted member 103

Guest
I mean a dynamic change.
since I sell these devices the customer should make the change. that is not possible.
 
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
you might check if with prototype device you can get stable transmission as I outlined.
maybe when you have found an optimal combination that setting will work more generally.
 
Upvote 0
D

Deleted member 103

Guest
you might check if with prototype device you can get stable transmission as I outlined.
maybe when you have found an optimal combination that setting will work more generally.

It also works to 99% right.
As I wrote above
The communication with my app actually works properly, only in rare cases, if the Bluetooth device is installed in some oldtimer car, the communication is disturbed.
I think the interferences perhaps come from certain spark plugs,
because with most oldtimer cars there are no problems.
The question is: can the interferences of these spark plugs be filtered out?
 
Upvote 0

mrred128

Active Member
Licensed User
Longtime User
The big factor is if you are using hardware serial ports or software ones. Software get's unreliable above 9600. Hardware can go easily to 115200. Arduino's (nano's and so on) only provide software serial while the mega and due have hardware serial ports.

Faster data rates also require better time sensitive code. The Due is 4x faster than the mega or arduino (random PI benchmark), so it will give you more latitude to be sloppy. :)
 
Upvote 0
D

Deleted member 103

Guest
Hi @mrred128 ,

many thanks for your response.
I use an Arduino-nano and connect the 2 ports (RX + TX) with the HC-06, the baud rate stays at 9600.
So the transfer should actually remain problem-free.
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
Hi Filippo.
You cannot trust a TTY protocol . Some more evoluted packet protocol should solve any issue.
Using low rates(<= 9600) I was able to transfer programs from a PC to thousands of CNC using a simple 3 wire RS232 on cables longer than m.100. But I had USART's on both side. And suitable XTAL's as well!

Mauro
 
Upvote 0
Top