HC-05 Bluetooth not answering AT commands
csae8126
Posts: 14
in Propeller 1
Hello, sorry for asking again a question...
I got a HC-05 bluetooth module on a FC-114 (state and enable pin) breakout board. I wired it the following way:
State -> NC
RX -> Propeller pin 27
TX -> Propeller pin 26
VCC -> +5V
Gnd -> Gnd
En -> NC
Pin34 -> + 3,3V (i soldered a wire to it)
What i do is, i disconect the VCC strip, power up my breadboard load my programm to the propeller, connect the vcc pin.
The bluetooth module goes to AT- mode, the leds begin to flash slowly (2 sec on, 2 off).
But when i send AT\r\n or anything else i do not get an answer. But what i noticed is, that if i send AT plus only $0d the module stops blinking. For me this means it receives data...?
Can anyone give me an advice? Thank you all
CON
_clkmode = xtal1 + pll16x 'For full 80 Mhz
_xinfreq = 5_000_000 'Use 5 MHz accurate crystal
OBJ
pst : "Parallax Serial Terminal"
Bt : "Parallax Serial Terminal"
PUB main | c
pst.Start(115_200)
bt.StartRxTx(26, 27, 0, 38_400)
repeat
c := pst.CharIn
bt.Char(c)
if(c == $0D)
bt.Char($0A)
repeat
waitcnt(clkfreq/2+cnt)
c := bt.CharIn
if(c>0)
pst.Char(c)
while c>0
I got a HC-05 bluetooth module on a FC-114 (state and enable pin) breakout board. I wired it the following way:
State -> NC
RX -> Propeller pin 27
TX -> Propeller pin 26
VCC -> +5V
Gnd -> Gnd
En -> NC
Pin34 -> + 3,3V (i soldered a wire to it)
What i do is, i disconect the VCC strip, power up my breadboard load my programm to the propeller, connect the vcc pin.
The bluetooth module goes to AT- mode, the leds begin to flash slowly (2 sec on, 2 off).
But when i send AT\r\n or anything else i do not get an answer. But what i noticed is, that if i send AT plus only $0d the module stops blinking. For me this means it receives data...?
Can anyone give me an advice? Thank you all
CON
_clkmode = xtal1 + pll16x 'For full 80 Mhz
_xinfreq = 5_000_000 'Use 5 MHz accurate crystal
OBJ
pst : "Parallax Serial Terminal"
Bt : "Parallax Serial Terminal"
PUB main | c
pst.Start(115_200)
bt.StartRxTx(26, 27, 0, 38_400)
repeat
c := pst.CharIn
bt.Char(c)
if(c == $0D)
bt.Char($0A)
repeat
waitcnt(clkfreq/2+cnt)
c := bt.CharIn
if(c>0)
pst.Char(c)
while c>0
Comments
Check first if something is in the receive buffer before you read a character: Not sure if the LF ($0A) really needs to be filtered out for the PST.
Andy
I was sending "AT", $0D, $0A
I have only worked with the HC-06 modules which are always in Slave mode and start with a 9600 Baudrate. Then you can change the Baudrate with a command.
Andy
I have some code which uses the enable pin connected to on of the Prop I/O pins to set it to command mode. I'll post a copy here soon.
Edit: Changed the phrasing of my post a bit.
The HC-05's enable line needs to be connected to the I/O pin defined by the constant "BLUETOOTH_KEY".
The Bluetooth module can be powered on with the Propeller. Any baud changes won't take effect until the Bluetooth module's power has been cycled.
I tried to add enough debug statements to the code to make the programs relatively self explanatory.
You'll notice the constants for a 10MHz crystal are used but the program will run just fine on Propellers using either a 10MHz crystal or a 5MHz crystal. I used some clock trick I learned (copied) from Phil to make the program automatically adjust to the crystal used (as long as it's either 5MHz or 10MHz).
Many of the HC-05 AT commands are listed in the "bridge" program's debug statements.
Both programs should find the current baud setting of the HC-05 module and let you know what this is. You don't have to know the baud setting of the module in advance.
Edit: I see the info Andy posted has this information about the two possible command baud settings. I hadn't seen this information prior to my experiments. I had to learn this the hard way.
No chance, it will not give me taht ok...
@Duane Degn: Both programs are not able to talk to the module. Im having one of those with a push button on it. There is a VCC, GMD, RX, TX, State and one Enable pin. What i did was soldering a wire to pin 34 of the module. Seting it to high when the module powers on seems to put it to AT mode (led flashing slowly).
I changed my code to the following
CON
_clkmode = xtal1 + pll16x 'For full 80 Mhz
_xinfreq = 5_000_000 'Use 5 MHz accurate crystal
OBJ
pst : "Parallax Serial Terminal"
Bt : "Parallax Serial Terminal"
PUB main | c
pst.Start(115_200)
pst.Dec(bt.StartRxTx(26, 27, 0, 38_400))
pst.NewLine
DIRA |= (1<<25)
OUTA |= (1<<25)
repeat
if pst.RxCount > 0
pst.Str(string("loop"))
pst.NewLine
c := pst.CharIn
bt.Char(c)
if(c == $0D)
bt.Char($0A)
if bt.RxCount > 0
c := bt.CharIn
if(c > 0)
pst.Char(c)
The BT- module sends me endless $00, therefore i check if c > 0 when reading from bt
Does anyone have an idea?
I tryed with 38400 and 9600 baud.
Sorry about that. I misread your original post and thought you wrote "without" breakout board.
You'd need to do a bit of soldering to get my code to work with your board. I think you could get my code to work with your board if you added a connection from the Prop to the HC-05's enable pin. The button shouldn't interfere with the enable pin as long as it's not pressed.
(Edit: It looks like you already did this.)
Connected the hc-05 via bluetooth to my pc.
When i try In putty on my pc i receive the chars...
When i try to send from my pc to the propeller i just get $00. This indepenet if i enter something in putty or not. As soon as the bluetooth module is powered up it sends zeros.
Could anyone imagine what im doing wrong?
Is Pin 34 on the module still connected to 3.3V?
It sounds like the module is able to send data to the PC over Bluetooth so I imagine you've disconnected the wire. Right?
Which Propeller board are you using? What are you using as a power supply?
Do you have a link to the Bluetooth module you purchased?
It might help people diagnose the issue if you posted a photo of your setup.
Pin 34 is not connected any more.
Im not using a Propeller board, i have a simple setup on a bread board. I use a laboratory power supply, delivering 5V. The bluetooth module is running direct on the 5V rail, as it has an voltage regulator on board. The power supply shoud be fine, because the whole setup is consuming not mire then 300 mA.
I bought it on this website: http://www.arduitronics.com/product/55/bluetooth-serial-module-hc-05-master-slave-mode
What i have to mention ist, that i have connected a prop plug on pins 31+30, an eeprom an pins 29+28, and on 27+26 the bluetooth module is connected.
I try to draw me setup in eagle and upload it later.
Do you also have a 5MHz crystal?
I know a lot of people disagree with me about this, but IMO, I think people are better off using a Propeller on a Parallax board like the Propeller Project Board. I just think there are just many more ways of hooking up a Propeller incorrectly on a breadboard than there are correct was of hooking things up.
I personally use breadboards a lot (but with an external Propeller board). Sometimes it helps to pull up the circuit and move it to a different section of the breadboard. I've been surprised how many times moving a circuit to a different location has solved hard to troubleshoot problems.
You might want to try communicating directly with the HC-05 with the Prop Plug. You should be able to send AT commands from the PC through the Prop Plug.
But it is a good idea to move it to a different section of the breadboard. Even tough a connectivity test worked out well.
Il try it and let you know wheter it worked or not. If it should not work i hook that module up to an arduino and ill try it with that.
Same result, rx on bluetooth module works fine, tx does not work at all.
Im going to order a new hc-05 module, to see if it works with that.
Il keep you up to date whats going on.
Just buy a cheap HC06 Bluetooth unit from ebay and use JonnyMac's BT Commander coding from this post.
I found it to be robust and stable and I use it all the time as a controller.
http://forums.parallax.com/discussion/159920/android-control-of-propeller-using-joystick-bt-commander-app-spin-code
You might want to replace the solder on the tx pin.
The HC-06 modules are fine but they are slave devices only. The HC-05 can be used either as a slave device or a master device. It's possible for use two HC-05 units for Prop to Prop communication. You can't use two HC-06 units this way.
I don't think there is anything the HC-06 can do which the HC-05 can't but the HC-05 has many features lacking in the HC-06.
I've used the HC-05 many times with the Propeller and it works fine with Joystick BT Commander.
I know a lot of people (myself included) assumed the HC-06 was an upgrade to the HC-05. This is not the case. The HC-05 is a much more capable Bluetooth module than the HC-06. The only reason I can think of to use a HC-06 instead of a HC-05 is if the HC-06 cost significantly less than the HC-05.
Today the new hc-05 arrived, put it back where the old one was and it works without any problems...
So it was the module it self.
I would like to say thank you to everyone who helped me at this topic!
But i will try to resolder the TX-pin, to see if i can get the old one to work too...