Shop OBEX P1 Docs P2 Docs Learn Events
HC-06 Bluetooth Problem/Question — Parallax Forums

HC-06 Bluetooth Problem/Question

NWCCTVNWCCTV Posts: 3,629
edited 2015-04-07 01:41 in General Discussion
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

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-03-24 19:28
    Looking at the website you refer to, I see the default baud rate is 9600baud.

    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?
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-03-24 19:43
    I was just testing the device. I am sure there is documentation somewhere. I know there are several people here that have played with these which is why I was asking. Now I just need to figure out how to dial back the Baud and or reset the device to it's original settings.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-03-24 19:55
    http://www.google.com.tw/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&ved=0CC8QFjAD&url=http%3A%2F%2Fwww.tec.reutlingen-university.de%2Fuploads%2Fmedia%2FDatenblattHC-05_BT-Modul.pdf&ei=OiASVbLsEoPW8gXRiYCgCQ&usg=AFQjCNG2p-ptgvFrzIBr1aTx-J62IEglhQ&sig2=P-g4HwkIyd_Z3tXyTeFVQA

    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.
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-03-24 20:39
    As Phil pointed out, you'll want to set your host device to 115200 baud. I've used the HC-06 at this baud rate in a couple tests.
  • John AbshierJohn Abshier Posts: 1,116
    edited 2015-03-24 20:56
    From original post: Teraterm but I get nothing back when typing in AT or any of the relevant commands for it

    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
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2015-03-24 21:01
    re: What this means is that one cannot simply type commands in through a terminal.


    You can try to copy and paste the commands instead of typing them.
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-03-25 07:20
    Many editors allow macros. Since I use PST all the time, I wrote a configuration program for the HC-06 that runs on the Propeller. It allows me to type

    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.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-03-25 07:32
    Since I don't have an HC-06 yet, this is just speculation -- but seems worth discussing.

    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.
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-03-25 08:39
    But once that is left, you seem to have to identify yourself for the unit to begin communications.

    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).
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-03-25 09:10
    I did read the whole document as seem that the name and password seems to be only for the active Bluetooth to recognize another Bluetooth. Master and Slave modes operate differently and it seems as if the slave has to login with the master Bluetooth device as a security feature (Am I correct?)

    ++++++++++
    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.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-03-25 16:55
    Just to clarify, I can type AT in with all other units and it returns OK like it is suppose to. It is only the one that the Baud was changed that is not responding.

    EDIT: The same goes with Jonny Mac's updated program. AT returns OK on all but the one that I changed the Baud on.
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-03-25 18:44
    You cannot type directly into that device -- the timeout period is too short.

    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).

    AT returns OK on all but the one that I changed the Baud on.

    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.
    pub set_baud | check, baud
    
    '' Sets new baud rate into HC-06
    '' -- limited to FDS-friendly baud rates
    '' -- restarts serial connection to bt module at new baud rate
    
      if (parser.token_count <> 2)                                   ' check token count
        term.str(@UseHdr)
        term.str(@BaudMsg)
        return
    
      check := parser.token_is_number(1)
    
      if (check)
        baud := parser.token_value(1)   
        [color="#FF0000"]check := lookdown(baud : 1200, 2400, 4800, 9600, 19200, 38400, 57600, {
                 }               115200, 230400, 460800, 921600, 1382400)[/color]
    
      if (check == false)
        term.str(string("Invalid baud setting", term#CR))
        return
    
      ' set new baud in module and connection
    
      buffer.reset                                                   ' clear buffer
      buffer.puts(string("AT+BAUD"))                                 ' set command string
      [color="#FF0000"]buffer.putc(CHAR_SET[check + 2])                               ' use hex char[/color]
    
      set_and_get(buffer.addr)                                       ' update module
    
      term.str(string("-- resetting BT baud", term#CR))
      
      btio.start(RX2, TX2, %0000, baud)                              ' reset serial link
      pause(50)
    
      set_and_get(string("AT"))      
    
    
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-03-26 01:17
    NWCCTV wrote: »
    Just to clarify, I can type AT in with all other units and it returns OK like it is suppose to. It is only the one that the Baud was changed that is not responding.

    EDIT: The same goes with Jonny Mac's updated program. AT returns OK on all but the one that I changed the Baud on.

    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/
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-03-26 08:00
    Okay.... I would like clarification as to whether you attempted to set the baud to 115000 or to 115200.

    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....
    {{
    
      Source: http://wiki.pinguino.cc/index.php/SPP_Bluetooth_Modules
    
      HC-06 AT commands
      
       * AT commands can only be sent to the device using a wired, not wireless, connection.
      
       * The bluetooth device will only respond to AT commands before it is paired/connected.
      
       * AT commands do not need a terminating CR/LF sequence.
      
       * AT commands must be entered quickly (cut and paste or use macro).
    
       
      The HC-06 firmware has a very limited subset of AT commands as listed below:
      
       * AT responds OK
    
       * AT+BAUDn where n = 1..C
         1=1200, 2=2400, 3=4800, 4=9600 (default), 5=19200, 6=38400, 7=57600, 8=115200, 9=230400,
         A=460800, B=921600, C=1382400 
         -- Responds OKnnnn. Retained across power offs.
         
       * AT+NAMEname where name 20 or fewer characters. Responds OKname. Retained across power offs.
       
       * AT+PINnnnn sets the pairing password. Responds OKsetpin.
       
       * AT+Pn where n is N (no parity), O (odd parity) or E (even parity). Firmware version higher than Linvor 1.5 only.
       
       * AT+VERSION responds with the firmware version.
    
    }}
    
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-03-26 19:11
    Sorry, It was 115200
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-03-26 21:14
    @JonnyMac, I get the error "Expected an Expression Term" at the following line: if (parser.token_count <> 2)
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-03-27 07:32
    I have no idea what's happening at your end.

    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.
    1024 x 576 - 337K
    800 x 600 - 350K
    720 x 1280 - 212K
  • PublisonPublison Posts: 12,366
    edited 2015-03-27 08:03
    Jon,

    Your configurator program in Post #8 compiles fine on this end.

    Andy must have gotten a bad download.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-03-27 17:28
    Publison was correct. I re downloaded the zip file and the program now runs correctly. @JonnyMac, please don't get discouraged. I have used your WS2812 Code with great success.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-03-27 21:25
    Jon,
    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.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-04-02 01:26
    Finally after about 6-7 months in limbo, my HC-06 arrived from Deal Exteme.

    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?
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-04-02 09:23
    I've ordered both board types -- I used the ones without a carrier to make an add-on board for the Propeller-powered HC-8+ (EFX-TEK). Last week I hacked a socket onto my DC22 badge and wrote a small Android app to control the WS2812s on the badge from my phone (that made people happier than I expected).
    800 x 600 - 350K
    960 x 720 - 633K
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-04-02 10:12
    Well, this is what I have when I say no carrier board. I guess that is no breakout board either.

    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.
    459 x 519 - 26K
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-04-02 13:10
    Yep, that's what I soldered onto a carrier for the HC-8+ controller project. I've attached my schematic for that in case you find it helpful.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-04-04 02:41
    @JohhnyMac

    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.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-04-04 06:15
    Here is my quicky HC-06 fix. I suspect I could add an SMD 0.01MDF capacitor easily between Vdd and Gnd if necessary. I am going to wait and see how this performs. CTS to RTS are not looped... not sure they need to be.

    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.
    959 x 1279 - 290K
  • prof_brainoprof_braino Posts: 4,313
    edited 2015-04-06 12:26
    Here is my quicky HC-06 fix. -- 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!
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-04-07 01:41
    Well, I finally got the "HC-06 Quicky" confirmed in actual operation. This past weekend was Tomb Sweeping Holiday and I couldn't find time to test it.

    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.
Sign In or Register to comment.