HC-05 Bluetooth Module Fails at High Baud Rate 460800 [SOLVED]

Hello all!

I'm working on creating a connection between two Arduino Unos via Bluetooth HC 05 modules.

I've been able to establish this connection with Baud rates at or below 115200 bps. However, I need to accomplish a baud rate of 460800 which the HC 05 is rated for in its data sheet.

I've also been able to establish a connection with baud rates up to 4Mbps when the two Unos are directly connected by jumper cables.

It's pretty clear that these HC 05's refuse to work at this higher baud rate. I have updated the HC 05 baud rates correctly using AT Command mode repeatedly without issue so I'm not sure the issue.

Any help would be appreciated.
Thank you!
-Rhodes C.

I suspect the issue is with the Arduino rather than the HC-05. I thought 115200 was at the upper limit of what a normal Arduino could manage reliably. Maybe somebody with more knowledge can confirm or correct me if I am wrong.

The baud rate is the speed the HC-05 is communicating with the Arduino. It is not the speed at which the BT modules are talking to each other. This is not user controllable and the actual speed is based on a number of factors such as signal strength and noise.

Is there any reason why you must use 460800?

I think it is the other way round. I am sure I have read of Arduinos communicating by wire at 500000. God only knows why you would want to do that. I'm hardly game to ask why you need 460800. HC-05 datasheets imply you can work at that speed.

I just Googled it. 2,000,000 baud is possible without problems and it looks like it will go to 250,000 bps at a push.

https://forum.arduino.cc/index.php?topic=21497.0

So 460800 isn't likely to the Arduino (unless you are using software serial).

The Atmega328 datasheet has tables showing how accurately it can match different baud rates. Some baud rates have significant errors. 500,000 baud works with no error (and I use it regularly. It does not list 460,800 but 230,400 (which is half) has an error of 8.5% or 3.5%

I have no idea whether the Arduino IDE chooses the setting that give the high or low error. Maybe you could improve the performance at 460,800 by setting the regsiters yourself.

...R

Wow! Thank you all for your replies.

I appreciate it very much.

Fortunately, I'm able to definitively say that the issue is not the Arduino because I can run a program on the Arduinos and have them communicate effectively at these high baud rates by jumper cable. It's only when I attach the HC-05's that the system fails, even with the same code.

However, if I drop the baud rates across the board (Arduinos and HC05's) to 115200, everything works as intended.

The other important thing of note here is that I'm not getting errors, I'm just not receiving any data at all. Nothing is being received.

@MartynC: I'm working with an already established system that requires a max speed of 375k because it reaches that speed at peaks. I'm just trying to develop a proof of concept of prove that I can in fact manage that speed.

Thank you all again for your help. Does anyone have other ideas what may be the issue because I am still facing this issue.

rhodesconover:
Fortunately, I'm able to definitively say that the issue is not the Arduino because I can run a program on the Arduinos and have them communicate effectively at these high baud rates by jumper cable.

Alas, you have not proved what you think you have proved. The Ardunos may be communicating happily because they are both wrong to the same extent.

...R

@Robin 2, that's true. While unlikely, it's certainly possible that the Arduinos are equally incorrect.

What methods would you recommend in checking the baud rate the Arduinos are running at?

Additionally, does anyone have any insight into why the HC-05 modules may not be running at their advertised baud rates?

Thanks all!

rhodesconover:
@Robin 2, that's true. While unlikely,

Rather than unlikely I suspect it is almost certain.

What methods would you recommend in checking the baud rate the Arduinos are running at?

Either an oscilloscope or another serial device that is working at the correct baud rate. I suspect the HC05 would be a suitable test device :slight_smile:

Additionally, does anyone have any insight into why the HC-05 modules may not be running at their advertised baud rates?

Why do you think they are not. My strong suspicion, based on the Atmega datasheet, is that the Arduino is wrong.

...R

@Robin2:

I suspect the Arduinos are correct for the following reasons:

  • I've tried making a Serial connection between the two Arduinos via Jumper Cables with at least 6 different baud rates. Each of them worked successfully. Therefore, I can assume that the Arduinos can handle various baud rates including baud rates well above the 480600.
  • I've also managed to create a Serial connection between the two Arduinos through the HC05s at various baud rates, but none above 115200.

Basically, the Arduinos have no trouble communicating with each other over Serial at virtually any baud rate. So potentially, the Arduinos could be perfectly in time with other, but incorrect, for all of these baud rates. For example, both Arduinos could running at half the expected baud rate, e.g., 4800 advertised is actually 2400 for the Arduinos. That could be true, except:

They also don't have a problem working with the HC05s as the middle man at lower baud rates. For any baud rates below 115200, the Arduinos are operating at the correct baud rate because they do interact correctly with the HC05s. It's only when they get above that value that they stop communicating. This definitely suggests to me that the Arduinos are not simply out of time, but in tune with each other, because that somehow only occurs at those higher baud rates.

However, I am definitely newer to this. You said that the Atmega data sheet suggested to you that the Arduinos are wrong. What in the data sheet suggests this to you?

I don't have access to an oscilloscope and I don't think testing the Arduinos with the HC05s would really be very logical, being I'm still unsure if the HC05 can handle that kind of baud rate. I have a Leonardo I could try to interface with but I'm not sure how I could check if it's working other than just sort of trusting that the Leonardo wouldn't be suffering from the same "out of time" issue that the Unos are, if that makes any sense.

Thanks for your repeated and helpful responses!

rhodesconover:
I suspect the Arduinos are correct for the following reasons:

I've tried making a Serial connection between the two Arduinos via Jumper Cables with at least 6 different baud rates. Each of them worked successfully. Therefore, I can assume that the Arduinos can handle various baud rates including baud rates well above the 480600.

You are not thinking about this logically. What you are doing is the equivalent of watching two german speakers communicating perfectly and then wondering why one of them cannot talk to a french speaker. Or maybe a more apt analogy (that would be understood by British people) is two Scotsmen talking english to each other but a man from Somerset being unable to understand them unless they talk very slowly.

I've also managed to create a Serial connection between the two Arduinos through the HC05s at various baud rates, but none above 115200.

To my mind that is further evidence for the problem being on the Arduino - over that speed the error becomes unacceptable.

Have you carefully studied the Atmega 328 datasheet?

...R

Edit see Reply #14 for a better analogy

Robin2:
You are not thinking about this logically. What you are doing is the equivalent of watching two german speakers communicating perfectly and then wondering why one of them cannot talk to a french speaker.

But that doesn't make sense to me. Because I have witnessed the "German and French speakers" speak to each other very well in the past with other baud rates. It's not like the HC05 and Arduinos have never successfully interacted: they've worked repeatedly in the past with lower baud rates.

The Arduinos can handle the required baud rate in some form or another because they have done it.
The Arduinos can also handle communicating with the HC-05s because they have done so at lower baud rates.

The only issue is when I have the Arduinos communicating at this level of baud rate through the HC-05s. It doesn't really make sense to suggest that these two devices are completely incompatible (as you compared to the two devices speaking fundamentally different languages) because they have been able to speak to each other in the past.

Robin2:
To my mind that is further evidence for the problem being on the Arduino - over that speed the error becomes unacceptable.

Are you suggesting that the Arduinos are dropping all received information at these baud rates because they determine the error rate is too high for the data to be valid? It's important to note that I'm not getting jumbled data, I'm getting no data whatsoever. Unless the Arduinos are actively dumping this data because it has determined the error rate is too high, I should get something at these baud rates, even if it's gibberish: but I'm not receiving any data at all.

Further, the error should not be unacceptable at those speeds for either device: The Arduinos can handle this kind of speed because they have repeatedly been able to do so via jumper cables/other mediums. The only issue is when the HC05s are included. The HC05s should be able to handle these kinds of speeds because the data sheet for them specifically says that they can handle this baud rate.

I dont' see any evidence that the issue lies with the Arduinos and a distinct lack of evidence, outside of that data sheet, that the HC05s can handle this kind of speed. HC05s have failed to transmit at this speed in every test I have done so far.

Robin2:
Have you carefully studied the Atmega 328 datasheet?

I likely have not studied it as thoroughly as you have. However, I am aware that it does say the max baud rate for an Atmega328p Serial line with an external oscillator providing a 16MHz clock is a 2Mbps baud rate, which is well above my required 480kbps (approx.).

What in the data sheet suggests to you that the Arduino can not handle these kinds of baud rates given that the system has demonstrated to me that it can do so in practical tests?

As I don't have your equipment to test I am not claiming to be 100% correct but let's wait to see if any other experienced Forum user disagrees with my analysis.

Do you understand the Scotsmen / Somerset men analogy?

...R

Robin2:
As I don't have your equipment to test I am not claiming to be 100% correct but let's wait to see if any other experienced Forum user disagrees with my analysis.

I understand. I'm not completely sure what you're claiming other than that the issue is with the Arduinos. Do you think the issue is that Arduinos can't manage baud rates that high? Are you claiming that they interpret baud rates differently than the HC05s? I know I'm new to this and you are experienced in it, but I don't know what I can do to effectively test your claims because I'm not sure what they are.

Robin2:
Do you understand the Scotsmen / Somerset men analogy?

I understand the idea of two devices that don't speak the same language having trouble communicating with one another. I'm just not sure if it applies here because both devices are supposedly using Serial communication at the same baud rate. The Bluetooth modules are just passing along German words, they're not trying to interpret them at all.

I'd say a better analogy is two people are speaking German to each other. They're very fluent and can manage 4 Million words an hour. But then, I give them two phones and tell them to go to different rooms and talk over the phone. That phone is rated to allow them to speak at 400k words per hour. However, when I give them the phone, they are fine communicating at a quarter of that, but when they start speaking faster, the phone cuts out. That makes me wonder if the phone is as good as it claims it is or if I'm using the phone incorrectly. To me, it doesn't make sense to think that the two Germans are incapable of speaking at a certain speed but only on the phone.

Again, I know you have a lot more experience than me: just trying to provide as much clarity for my viewpoint.

rhodesconover:
I understand the idea of two devices that don't speak the same language having trouble communicating with one another.

I guess my German - French analogy was not very good. The point about the Scotsman and the Somerset man is that they both speak english but with a very different accent. I am not sure whether similar differences occur in the spoken language in other countries so that a speaker from one area might have difficulty understanding a speaker from another area.

To try to recover my multilingual example, consider a couple of Irish kids (I'm Irish) who learned German badly in school - they may be able to talk to each other in German but still not be able to understand a native German speaker unless he spoke very slowly.

...R

Okay that makes sense. You're suggesting that the issue is that the Arduino and Bluetooth module aren't understanding each other due to some type of difference in protocol (whether intentional or not).

Technically speaking: what do you think that protocol difference is? A baud rate difference? A different number of data bits? A different voltage level? There are plenty of potential issues beyond the ones I listed here. Without a direction to go, it's hard for me to do any sort of testing.

Thanks!

rhodesconover:
Okay that makes sense. You're suggesting that the issue is that the Arduino and Bluetooth module aren't understanding each other due to some type of difference in protocol

No. Just an inability of the Arduino to generate the timing to detect bit values at the high baud rate that you want to use.

Do you understand how incoming serial data is detected? Everything is timed from the HIGH - LOW transition of the start bit. if the timing is not accurate enough the receiver will not be sampling the signal at the correct instants. At lower baud rates each bit state lasts for a longer time so that small timing errors may not cause a problem.

The baud-rate divisors used in the Atmega 328 cannot perfectly produce the timing needed for 115200 baud (or its multiples) from the 16MHz clock. If you could run the Atmega 328 at 12MHz you would probably have no difficulty. If you had studied the Atmega 328 datasheet as I suggested in Reply #4 you would understand this.

...R

Robin2:
No. Just an inability of the Arduino to generate the timing to detect bit values at the high baud rate that you want to use. If the timing is not accurate enough the receiver will not be sampling the signal at the correct instants. At lower baud rates each bit state lasts for a longer time so that small timing errors may not cause a problem.

This makes sense. I'm following you now. Because the baud rate is getting higher, the width of the bits is shrinking. Additionally, because I'm using a 16MHz clock, my Arduino cannot accomplish this baud rate without some degree of error. Therefore, once I hit a certain level of speed, the error from my Arduino's baud rate may send signals just slightly out of time with what the Bluetooth module expects, and it starts sampling at incorrect locations and gets confused and drops the data. This doesn't occur at lower speeds because the bits are held for much longer periods of time and because the Arduino has a reduced level of error of baud rate timing.

Two options I can look into are either 1.) stay at lower speeds in general (to keep the width of bits up) or 2.) pick alternate higher speeds that have less error on the Arduino end (that still work with the Bluetooth module).

Am I on the right track? Thank you again for your help!

rhodesconover:
Am I on the right track?

Finally :slight_smile:

...R

Thank you for your help and sticking through it with me not understanding you. It's unfortunate that I'm going to have to either provide an external oscillator for my Arduinos or find a different setup but at least I think I know what's wrong.

If anyone else has any alternate theories for what the issue might be, feel free to post: I'd pretty happy if I didn't have to change my direction up too much.

Thanks again, Robin2!