Hey all. I'm hoping that this is going to be my last setback for a while lol... but I doubt it!
I have 3 HC-05 Bluetooth modules so im not to worried if I break one(cos there cheap)
After a little bit of reading and trial and error i finally have this module up and running(sort of)
Ill post pic's of the device i have at the end of this post.
From the advice of many a forum post, I have a voltage divider from my Arduino Uno TX to the HC-05 RX pin which is 3.3v
The thing is. Receiving data from the Uno's TX to the Modules RX is rather sporadic. Either i get no data, or i get garbled data. or i get the actual data.
Now. as an experiment, i removed the ground for the voltage divider(risky I know, but these modules are cheap to replace) Which changed the modules RX voltage to 1.53v
I use a 1K and a 2K resistors for the voltage divider on my HC05 projects with really good success. It may be that the divider made with 10k and 20K will not pass enough current for solid levels. I have no explanation why disconnecting the ground works, but I doubt that it is a good solution. Putting 5V on the HC05 may "work", but there is a reason that the level shifter is recommended by the people that know so I always use the divider.
Looks like im going shopping come payday lol till then. I dont mind burning out one hc05 for testing purposes lol if removing the ground works ill stick with that till i can order some more resistors.
While I have your attention. Could you point me to where I can find the AT commands info? As iv still not managed to get an OK responce yet ? Do i need +3.3v on the en/key pin if i have a button? Does the button only get me low level access to AT mode and the en/key pin with 3.3v gives me full access? Theres so many variations on the hc05 that im getting lost.
I connect the EN pin to 3.3V to access the AT mode on my HC05 modules. I have used the button held closed with an alligator clip as well. Both seem to get me full access to AT commands. The baud rate for AT mode is 38400.
I hear that. Throw in that there are some bogus modules out there and it gets worse. There have been several times that I have been trying to help someone get theirs to work and nothing helped so they bought new modules from a different vendor and those worked with no problem. Buy from a reputable vendor and your chances are much better.
Here is the program that I use to set up my HC05 modules using AT commands. It is written for an Uno (or Nano) using software serial and can easily be modified to use a hardware port like on Mega. This code has been tested many times and I have seen no commands that do not work.
// AT command mode for HC05 by Martyn Currie
// modified by c goulding AKA groundfungus
// before powering up the Uno and module CONNECT EN TO 3.3V.
// connect software serial RX (Uno pin 2) to HC05 TX
// connect software serial TX (Uno pin 3) to HC05 RX through
// voltage divider (1K and 2K resistors)
// enter AT. First time may get ERROR.
// try again, should get OK.
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
const long baudRate = 38400;
char c = ' ';
boolean NL = true;
void setup()
{
Serial.begin(38400);
BTserial.begin(baudRate);
Serial.print("BTserial started at ");
Serial.println(baudRate);
Serial.println("Ready for AT commands");
Serial.println();
}
void loop()
{
// Read from the Bluetooth module and send to the Arduino Serial Monitor
if (BTserial.available())
{
c = BTserial.read();
Serial.write(c);
}
// Read from the Serial Monitor and send to the Bluetooth module
if (Serial.available())
{
c = Serial.read();
BTserial.write(c);
// Echo the user input to the main window. The ">" character indicates the user entered text.
if (NL)
{
Serial.print(">");
NL = false;
}
Serial.write(c);
if (c == 10)
{
NL = true;
}
}
}
A sample of the output:
BTserial started at 38400
Ready for AT commands
AT
ERROR:(0)
AT
OK
AT+PSWD
+PSWD:1234
OK
AT+NAME
+NAME:MASTER2
OK
AT+UART
+UART:9600,0,0
OK
When you issue a version inquiry (AT+VERSION?), what do you get? If it is 2.0-20100601 then this Martyn Currie post may be of interest. Most, if not all, of my working modules are of that version.
You sir are a gentleman and scholar. Thank you. Iv read most of Martyns doc regarding bluetooth modules but another read and a bookmark wont hurt.
Thanks again.
And, putting 3.3v on the EN pin does nothing. only holding the button on powerup gives me access to AT mode. When I get home im gonna try soldering a wire to pin 34 on the actual bluetooth module to see if that does anything.
You will not see any thing on the Bluetooth terminal. The only output will be on serial monitor. The code is only for using the PC to set up the HC05 in AT mode using serial monitor.
Please do not post screen shots. I cannot read it. Can't you just copy (ctrl-c) and paste the output into a post as text?
Is the serial monitor baud rate set to 38400?
Can you try holding the button with an alligator clip before powering the module and keeping it held after powering? That has worked for me. I have never had to solder anything to the module but the header for power and signals.
^^^^^^^^^^^^^^^^^^^ These asterix represent what im getting on my serial monitor. white squire diamonds with ?(question marks in the middle). two at a time.
baud rate is set to 38400 and i tried the alligator clip trick with no luck.
I don't know what to say. The code that I posted works as posted with the EN pin set to 3.3V. As you can see by the output that I posted, I tested the code and setup before I posted the code.
Might be time to invest in a module from a different and reputable vendor. You could have one of the bogus modules that are out there.
Yeah, could be. When my resistor pack arrives ill try setting up one of the other modules. Which i havent tested yet. Till then ill keep playing with this one. Are there other ways of reducing the voltage from the tx pin to 3.3v other than a voltage divider?
Ok, got my voltage divider up and running. All 3 modules work fine now. Except AT mode. The only commands that dont return an error are AT+ORGL and AT+RESET. Any ideas?