Hi
I have an HC-06 module that I'd like to configure, mainly to change the baud rate and possibly its name. I know that it works because I have successfully paired it with my cell phone using Bluetooth Electronics.
However, everything I tried to configure it using a Arduino nano did not work. It is correctly wired (VCC to 5V, GND, Rx to D2 with a resistance bridge, Tx to D3).
I tried several Arduino sketches such as
/* HC-06 Config est un programme qui permet de configurer le module Bluetooth*/
// Création d'une liaison série sur les broches 2 et 3
#include <SoftwareSerial.h> // appel de la bibliothèque
SoftwareSerial HC06(2, 3); // RX, TX
void setup()
{
HC06.begin(9600);
Serial.begin(9600);
Serial.println("Entrer la commande AT:");
}
void loop()
{
// si le HC-06 transmet, on écrit le message dans le moniteur série
if (HC06.available()) Serial.write(HC06.read());
// si on écrit dans le moniteur série, on transmet le message au module HC-06
if (Serial.available()) HC06.write(Serial.read());
}
but nothing works. When typing AT or any other AT command, there is no answer. The serial console does not display any answer. What's wrong ?
lesept:
It is correctly wired (VCC to 5V, GND, Rx to D2 with a resistance bridge, Tx to D3).
SoftwareSerial HC06(2, 3); // RX, TX
I bought it China
I just need to know its baudrate to use it. How can I know it ?
No, it isn't correctly wired. You appear to have Rx/Tx the wrong way round, and succesfully pairing it with your phone does not prove the communications wiring is kosher. There is probably nothing wrong with the code, and the fact that you bought it from China is irrelevant, they all come from China. The baud rate is 9600 by default. If that is all you need to know, you probably don't need to configure it, as they work fine out of the box.
You might find the following background notes useful.
You're right, it was Rx to D3 using bridge, and Tx to D2
The ino sketch you point to seems to work : each time I enter a character it gets repeated (only the last character when typing several). But it's not communicating with the bluetooth device (or maybe I don't understand correctly)
/* This is a simple test for two way traffic via bluetooth
but you can try it first using the USB cable to the serial
monitor without the bluetooth module connected.
Note that some bluetooth modules come set to a different baud rate.
This means you need to alter the command
Serial.begin(9600) accordingly
Same goes for the setting in the bottom right corner on the
serial monitor */
String readString;
char c;
void setup()
{
pinMode(0, INPUT_PULLUP);// only needed for JY-MCUY v1.06?
Serial.begin(9600);
Serial.println("OK then, you first, say something.....");
Serial.println("Go on, type something in the space above");
Serial.println(" and hit Send or Enter,");
Serial.println("then I will repeat it!");
Serial.println("");
}
void loop() {
while (Serial.available())
{
delay(3);
c = Serial.read();
readString += c;
}// end while
if (readString.length() >0)
{
Serial.write(c);
readString="";
} // end if
}
EDIT : Yes, I didn't understand correctly. Now I have connected Rx from BT to Tx from Nano, and vice versa. It doesn't work : I get the "welcome message" but when I enter a character, there is no answer.
Maybe I haven't explained it well enough. The code is for comms between Arduino and phone via bluetooth. You can have serial monitor on but just to look. Initial message comes up on phone after pressing rest button on Arduino. All it does is prove the point. If you get anything at all, the wiring and procedures are OK. The notes have more than one example of config for HC-06. If they are obscure, try the Martyn Currey site. Do not confuse HC-06 and HC-05 config. procedure.
I open the BT console on my Android device, discover the HC06 module and connect to it.
Up to now, ok: the console (Android) says "connected", the red led on the BT module changes rate (2 blnks in a second, then nothing for 5 seconds or so)
Then I type "hello" in the Android console and send it: nothing appears on the Arduino console.
If I type "Hello" in the Arduino console nothing appears on the Android console.
Is there anything I didn't do well? Or is it coming from the BT module?
OK, I did everything like you said and it works as expected. But...
I'd like to change the baudrate, increase it if possible up to 115200. I tried Martin Currey's sketch, select 9600 and 'no NL+CR' on the serial monitor, but I only get the message "Enter AT commands:". When I type AT, I expect OK as an answer, but nothing is displayed on the serial monitor.
I do the same connexions: the only difference is that I use 1.2k and 1.8k resistors.
IF you are getting two-way communication as I have described, it proves that your code, components, procedure, and wiring are all kosher. And I'm sure that includes the voltage divider, which should be the least of your problems.
The message "Enter AT commands:" comes from Arduino and doesn't prove anything about Bluetooth.
I'm afraid I am at a loss to explain this, but it can only be procedural, and I can only offer two wild longshots.
!. You are trying to configure via bluetooth, i.e. the phone. You can only do it via serial.
It's not an HC-06, it's an HC-05. I say this only in the light of recent thread on this forum, where it was pretty clear that was the case. The module was on a GW-040 breakout board, ahd four pins, and identified itself as "HC-06". A genuine HC-06 identifies as "LINVOR".
It's not an HC-06, it's an HC-05. I say this only in the light of recent thread on this forum, where it was pretty clear that was the case. The module was on a GW-040 breakout board, had four pins, and identified itself as "HC-06". A genuine HC-06 identifies as "LINVOR".
This describes the situation. What can I do in this case?
Not having seen a GW-040, the following are guesses.
If the board has a button by the KEY pin, try holding it down as you apply power. If the LED flashes at a much slower cycle, you are in AT mode. You only need top hold the button down momentarily. Arduino<>Bluetooth serial must be set at 38400 for config.
If there is a button but no joy, solder a new pin into the vacant KEY point, connect that to 5v, and try again.
If there is no button, you might apply 3.3v to pin 34, thereby bypassing whatever circuitry there is, or isn't, for this purpose. This can probably be done using a probe, rather than soldering a wire.
You might also reconsider whether you really need to use 115200, you probably don't and you already know that it works fine at 9600 but, if you do any of the above tricks, some feedback will be appreciated.
I believe you can verify this module is an HC-05 by checking voltage on pin 31, which is the LED. This pin is not connected on a kosher HC-06.