HC-06 Bluetooth Problem/Question
NWCCTV
Posts: 3,629
I purchased several of these BT devices on eBay and I am having an issue with them. Using the instructions here http://propellerpowered.com/shop/?page_id=1748 I was able to test all of the modules and when typing AT I got OK back. However, I changed the Baud rate on one of them to 115000 and now it shows up in Teraterm but I get nothing back when typing in AT or any of the relevant commands for it. Does anyone know what might have gone wrong and is it possible to fix?
Comments
You simply may have to dial back the speed until you regain communications and then look at the code involved. It is a serial device with all the usual associated problems -- buffers, latencies, and so on. Speed related problems could arise at any point in the serial communications link.
I have ordered one of these but am still waiting for it to arrive. So I am interested in your success. Do you really need more speed, or are you just testing?
Is 115000 correct, or does that need to be more precise -- 115200? 115200 baud is considered a standard rate.
Possible fixes? Much depends on how the change in baud rate occured. Was a boot eeprom overwritten, or was the change in RAM only? At times, rewritting to a boot eeprom can be difficult. RAM usually requires merely removing power for awhile and starting over.
Any documentation anywhere?
It is all new to me. Here is a link to more documentation. Not sure that the attempt to set 115,000 baud was successful. You might revert to 9600 and check.
Something in the documents mention that in 'communication mode', the AT mode is ignored. You might have to create some sort of loopback test if you have shifted to communication mode. I am very unclear about what this all may imply.
There is a reset pin that may take you back to a factory default if all else fails.
From JonnyMac's article in April 2015 Nuts and Volts: When in command mode, it (HC-06) does not use a terminating character (e.g., carriage return) for the command; it uses a serial timeout. What this means is that one cannot simply type commands in through a terminal.
John Abshier
You can try to copy and paste the commands instead of typing them.
BAUD 115200<CR>
... and then converts it to the appropriate HC-06 string
AT+BAUD8
It also resets the Bluetooth connection to the new baud rate and then pings (AT) the BT device. This makes it easy for me to find and change the baud rate of the HC-06.
Edit: I updated my configuration program to allow upper/lower case in the name, as well as spaces. I have tested this on my HC-06 that is presently hacked onto my DC22 badge. Note that my HC-06 was set to 57600 and I changed it to 115200.
Don't you have to provide a name and login initially? My impression that AT is a configuration mode. But once that is left, you seem to have to identify yourself for the unit to begin communications.
=========
Aside from that, I would investigate the nature of the Reset pin.
I have only scanned the document I provided a link to. I will read it in depth in the next 24 hours and try to follow along with what others suggest.
But I do see that pulling the Reset pin low might be a way to get a fresh start. It appears not to be wired to anything, but a 5K resistor to the pin and ground at the same time should do some sort of reset.... I am just not clear if that is a 'full reset' to factory defaults or a 'lesser reset' when your changes are still evolked.
If in doubt as to what to do, you should try to Ping the Version number as this doesn't change the configuration in any way. That doesn't require a loopback.
You can try a loopback by hardwiring TX to RX. This would eliminate having to investigate in the microcontroller's code is somehow at fault. There are other serial functions pins that might have to be set, such as CTS and RTS before a loopback will work.
Regretably, the document I found is obviously authored by someone with less than perfect English skills -- so some topics are difficult to sort out. But there is a reference to a website with further documentation... hopelfully useful.
No, you don't. The HC-06 behaves as a generic UART -- it simply passes data through like a wireless serial port (is uses the serial port profile).
++++++++++
I have been trying to come to grips with the idea that this HC-06 can be recovered or if it is possible to brick (make useless) one of these units by starting out with a bad configuration.
It seems not to be a topic that the maker desires to discuss. Searches don't come up with much as the HC-06 has acquired the nickname "The Electronic Brick" and that confuses the search engines.
I am searching "HC-06 failure and recovery" for possible resources.
EDIT: The same goes with Jonny Mac's updated program. AT returns OK on all but the one that I changed the Baud on.
My program -- as others have done -- allows for the construction of a string that the HC-06 can understand; being sent as a string means you won't get a timeout.
If you're seeing OK on the terminal, you're connected at the rate presently used by the HC-06. To change it with my program you do this:
BAUD 57600
...note the space and the desired baud rate, not the code that the HC-06 uses; my program reads your baud rate and converts it to the code. Note, too, that I only allow rates up to 115200. The screen shot attached to post #8 shows an actual transaction on my device where I changed the baud rate from 57600 to 115200. If you look closely you'll see that the initial baud command does not get an OK -- this is because that program starts with 9600 baud, the default baud rate of the HC-06. When you tell the program to change the baud of the HC-06 it resets the connection to the device as well, and issues an AT to verify the new rate setting. In the first instance the baud of the HC-06 was 57600 but the baud of the Prop-->HC-06 was 9600; the first baud command set the connection between the two to match. Once the Propeller baud matched the HC-06, all is well with command the program understands (type HELP<cr> to see them).
Using my program, try all known baud rates up to 115200. As I've shown above, you can ultimately connect. If you think you set it to 230400 or higher, you'll have to modify my program.
A few minutes later... Here's the modification you may want to make (I don't want to post this in the program archive as I don't think it's a good idea to use FDS above 115200. I tested all the way up to 460800 -- it worked, though I got some Smile characters back on PST (this could be due to other circutiry on my baord). In the end I was able to take it back to 57600 which I think is a good speed for the HC-06/Propeller.
Okay.... I would like clarification as to whether you attempted to set the baud to 115000 or to 115200.
If the baud was actually set to 115000, there is terminal software in Windows that can actually opperate at that odd-ball baud. But Teraterm may be frustrated in trying to comply to 115200.
You may have to use RealTerm at 11500 baud to get a response.
http://sourceforge.net/projects/realterm/
It's not possible to set the baud to a non-standard rate as the module doesn't accept the rate as a value, it takes it as a code.
AT+BAUD1 sets the baud rate to 1200
AT+BAUD2 for 2400
AT+BAUD3 for 4800
...etc, up to AT+BAUDC
From my program....
Just to ensure that I didn't upload something bogus (rarely the case), I downloaded the archive attached above and opened the top object from the ZIP file (again, not to confuse it with what's on my computer). Shocker, it works fine.
FWIW, I just used that program yesterday to update the HC-06 that I strapped onto my DC22 badge so that I could control the attached IronMac shield (10 WS2812 LEDs) from a custom phone app for Monsterpalooza this weekend.
I cannot remember a time where you've had success with anything I've shared with you. At this point I will just stop.
Your configurator program in Post #8 compiles fine on this end.
Andy must have gotten a bad download.
Thanks for the code. I am awaiting delivery of an HC-06.. so this will be very useful to get started.
The general consensus on the internet is that the HC-06 is easy to use and difficult to damage. So once the user has gotten it working right, it should be very handy.
I was surprised to see that I have just the module, no carrier board. But I also have found Propeller support that indicates that should not interfer with using it. In fact, it may make things simpler. Some of the carrier boards actually buffer the serial i/o. The Propeller can easily handle 3Mbaud if requried, so why deal with a potentially slower buffer?
It seems I simply need to wire up TX, RX, Vdd, and GND to a bit of perf board with 4 pins on it, and hot glue this to that backing. Trying to decide if the addition of KEY and LED(State) are worthwhile before I actually build something.
Next time, I will be more careful about shopping for something a bit easier to pop in and out.
Thanks for the schematic. I guess I am going to take the time to create a small single-sided board in Eagle and solder the HC-06 to that.
In the future, I will just order HC-06 boards with the carrier board -- even if more expensive. It is rather silly to just DIY everything and think that this is really saving money. These little details just delay getting to the real project.
From what little I understand, without the Key connected, changing baud rate or other AT configuration commands is a bit trick. I could solder another connector to the other side to make KEY and LED(state) pins available.
I did locate an HC-05 locally with carrier board and six pins for $12.00USD -- so this may be the last bare HC-06 I will ever order.
Hey, that's a really good idea. I have a bunch of HC-05 and HC-06 bare modules that I ordered before I realized we need the carrier board. I have not been able to consume them, your quicky fix should get those in service. Thanks for sharing!
Since the HC-05 offers more choices, you may have to think a bit more to get it wired right. Pinouts are definitely not all the same -- but Vdd, Gnd, Tx, and Rx are alike.
Works fine with serial terminal software. There have been lots of places that document the set up in Windows.
Using Linux.....
But I am using Debian Linux and had to configure a /dev/rfcomm0 serial port. There is Bluetooth recognition software that you just click and follow menus to get recognition and the MAC address (which you will later need) -- don't forget to also activate the Bluetooth in your system configuration. From there, I just had to edit one configuration file and reboot the computer to get my HC-06 recognized in an automatic fashion and assign a serial port to it /dev/rfcomm0
That works fine with minicom terminal. I haven't bothered to increase the baud rate - still 9600 8N1.
Everything is connected to a Propeller that is using Forth (in this case, pfth -- but PropForth or Tachyon should work just fine as long as the baud rates are set to 115200 or less. Supposedly, the HC-06 will suffer rf interferance at anything higher.
+++++++ CONSTRUCTION TIPS +++++++++++
Construction looks very simple and direct, but I suggest you take a bit of time to fit up the 8 pin connector. Obviously remove the 4 middle pins, and then bend the two inner pins to line up properly.
After bending the pins to get the right allignment, I used a small jewellers flat file to make all the ends the same length as the bent ones are shorter. And I gently used the same jewelers file to make the pins a bit narrower for a good fit. Fit everything well before soldering. If you make mistakes, start over with another connector.
When soldering. I had the HC-06 laying on top of a bit of perf board to get the pins to allign well. The SIP 8 pin device is fatter, so if you try to solder everything without elevating the HC-06 -- the pins are difficult to allign.
If you follow these suggestions and go a bit slow at first, you will get first rate results.
I also have had to add 4 pins to the Propeller project board to provide 3.3V power and the RX and TX. I'll try to post a photo of the complete set up later.
+++++++
Now I have Bluetooth to Forth on the Propeller --- very handy for remote control and development. This is where I really enjoy using Forth....... and inexpensive.
I previously got Wifi to Forth working with an MR3020 wifi modem hacked with open source firmware -- but that requires more power and more steps to get up and running. In some situations it may be more secure, but certainly less compact. That will also allow a CAT5 network interface to Forth on the Propeller if desired.
I suspect that if I got the baud rates correct for Simple IDE, Catalina C, or BST (I beliieve that these expect 19200 baud, but you should check) -- I could wirelessly load Propeller binaries of all sorts.
Lots more to explore.