I have some questions about HC-05. 1.) in the AT mode, I set the baud rate to 38400. In my Arduino code, does the Serial.begin() have to be Serial.begin(38400) to match it or can I set to Serial.begin(9600)? 2.) If I want to use the HC-05 but I still want to use the Rx 0 and Tx pins 1 on the Arduino, do I need to use the software library at all? Thanks.
Your post isn’t too clear but
1.) if you want to be in AT mode, Arduino can only talk to Bluetooth at 38400, irrespective of what port you are using to do that, and also irrespective of whatever rate you have set for communication.
If you want to communicate HC05<>Bluetooth, the two must have matching baud rates.
- You must not use software serial for any device on pins 0,1.
You might find the following background notes useful.
I am sorry my question was not quite clear. In the AT mode, I already set to use baud rate 38400. So let's forget AT mode for the moment. My question is I know that on the sender recive sides the baud rate must match 9600 sent 9600 receive etc.But if I set the default 38400, do the sender must use 38400? or can the sender and receiver use 9600?
When you set the baud rate, it applies to both send and receive. The
in your Arduino programme must match the rate you set in Bluetooth when you configured it in AT mode.
As an aside, the default baud rate for communications in HC-05 is 9600, not 38400. I mentioned this because, if you are having difficulty communicating Arduino<>Bluetooth, you might try doing it at 9600.