Using AT Commands to Set Up Your Bluetooth Module : HC-05 and HC-06

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 มิ.ย. 2024
  • You can easily add Bluetooth connectivity to your Arduino project with an HC-05 or HC-06 Bluetooth module. These work straight out of the box but at default settings for their serial speed, Bluetooth broadcast name, and Bluetooth pairing pin.
    You don't need to change the settings but it's a very easy process to go through, and you can use your existing circuit to allow your PC to talk directly to the Bluetooth module.
    In this video I'll show you how to use a range of AT commands to change the settings on your Bluetooth module using a very simple Arduino sketch to pass commands from your serial monitor through to the Bluetooth module.
    Make sure you visit the project page on my website for this video for more information, code and a list of AT commands for each of the Bluetooth modules.
    bytesnbits.co.uk/at-commands-...
    Bluetooth Modules
    Amazon:
    HC-05 module : amzn.to/3t6CjZE
    HC-06 (slave only) : amzn.to/3iY3jpE
    eBay:
    HC-05 : ebay.us/lUhUPn
    HC-06 (slave only) : ebay.us/I4cPwi

ความคิดเห็น • 48

  • @TheDemonking82
    @TheDemonking82 3 ปีที่แล้ว

    All this time I’ve been ripping my brains to shreds and there was a button. Thank you your so far the only one I found that points this out. And love the video.

    • @BytesNBits
      @BytesNBits  3 ปีที่แล้ว

      Hi. There's always a 'make it work' button that no one tells you about. Glad it helped.

  • @nara49veera12
    @nara49veera12 4 หลายเดือนก่อน

    Thank you for your clear description of each step and its purpose

    • @BytesNBits
      @BytesNBits  4 หลายเดือนก่อน

      You are welcome!

  • @AndrewBarber-Hobart
    @AndrewBarber-Hobart 9 หลายเดือนก่อน +2

    This is a great tutorial. Very clear and easy to follow. Thanks heaps.

    • @BytesNBits
      @BytesNBits  9 หลายเดือนก่อน

      Glad it was helpful!

  • @michaelodonnell4467
    @michaelodonnell4467 2 ปีที่แล้ว +2

    Great video's, I have been able to programme a HC-06, but can't get the HC-05 to respond to AT commands. Yes, it is in program mode ( pressed the button) and yes I have wired it as per instruction. I have tried two other HC-05, but none of them will respond. I have tried other baud rates but nothing. Any other suggestions are welcome. I have ordered some more HC-06 as I know they work. I need to increase the baud rate for a GPS-RTK project.

    • @BytesNBits
      @BytesNBits  2 ปีที่แล้ว

      Hi. That's strange. Are you running the basic terminal code to send your commands directly to the HC05? Is anything coming out of it? Have a look at the data sheet for your device to make sure you've got the right baud rate, stop and parity bit settings. If these are off it might not be able to read your commands. Good Luck!

    • @michaelodonnell4467
      @michaelodonnell4467 2 ปีที่แล้ว +1

      @@BytesNBits thanks. Yes have tried everything. I'll just stick to to the hc06 as they work

    • @robinarmstrong8886
      @robinarmstrong8886 ปีที่แล้ว

      Same problem and seems a common one but no one has any good answers other than replace the bluetooth module which I'm sure is not the problem.

  • @davidclarke92
    @davidclarke92 3 ปีที่แล้ว

    Hi. Is there an AT command to stop the Bluetooth device from broadcasting itself for new connections? Too add more security after changing the pin.

    • @BytesNBits
      @BytesNBits  3 ปีที่แล้ว

      Hi David. You can use the AT+CMODE=0 and then AT+BIND=??? to restrict the module to a specific bluetooth device connection. You'll need to use some of the other commands (have a look at this list content.instructables.com/ORIG/FI9/7NJR/IRXT0JIG/FI97NJRIRXT0JIG.pdf) to get the addresses of paired modules. I've not tried it or worked out exactly what to do but the commands seem to be there. I hope this helps.

  • @magwitch
    @magwitch 2 ปีที่แล้ว +2

    Hi, thanks for the HC-05 tutorials. I've tried to follow this tutorial exactly and don't get any response when I enter AT commands, I just stare at a blank serial monitor. Can anyone suggest what might be wrong?

    • @BytesNBits
      @BytesNBits  2 ปีที่แล้ว

      Have you checked your serial terminal baud rate? Try a few different settings to see if the speed on the HC-05 has been set to something different. Other than that, check your wiring, try a different HC-05 and Arduino if you have one. I hope you get it working.

    • @magwitch
      @magwitch 2 ปีที่แล้ว

      @@BytesNBits turns out you're supposed to short circuit two points together. Not sure how but that's how my teacher said they did it.

    • @BytesNBits
      @BytesNBits  2 ปีที่แล้ว

      @@magwitch Hi. Your teacher is correct - sorry forgot the HC-05 works differently to my HC-06. There should be a small button on the HC-05 unit. You need to hold this in as you turn on the power. This will put it into AT mode so it will talk to you. Set it up as you want and then power off and on again to get it back to normal mode. I hope this works!

    • @TheAakoo123
      @TheAakoo123 ปีที่แล้ว

      th-cam.com/video/ykgt4v7_4y4/w-d-xo.html

    • @TheAakoo123
      @TheAakoo123 ปีที่แล้ว

      Serial speed is by default 38400 in AT mode and you need to connect the key pin also on HC-05.

  • @jack-haywood
    @jack-haywood 10 หลายเดือนก่อน

    I followed along with you first video and everything worked, not changing any hardware settings I uploaded your code from this video and it does not work. Any suggestions?

    • @BytesNBits
      @BytesNBits  10 หลายเดือนก่อน +1

      If you've copied from the web page the top line has gotten corrupted by the editor
      #include
      should be
      #include ;

  • @robinarmstrong8886
    @robinarmstrong8886 ปีที่แล้ว

    Can someone explain why some tutorials connect to the TX/RX pins for programming and others use the Digital serial pins? Also every time I try this I get no output on the serial monitor...All these tutorials have comments from people with similar problems but no one seems to know the true reason why, and how to fix it?

    • @BytesNBits
      @BytesNBits  ปีที่แล้ว +2

      Hi. On some Arduino models (Uno and Nano) the digital serial port is shared with the serial port used to talk to your PC. If you use these pins for your project you then can't communicate with your PC whilst your code is running. This may be why you're not getting anything on the serial port. Using the software serial port gets around this issue. On boards with 2 hardware ports this isn't a problem.

  • @fernandohood5542
    @fernandohood5542 ปีที่แล้ว

    How do you send data from the device to another device after you connected?

    • @BytesNBits
      @BytesNBits  ปีที่แล้ว

      You'll need one arduino with an HC-05 module that can run as a master. This can then connect and disconnect to other devices.

  • @djdndhilo5440
    @djdndhilo5440 5 หลายเดือนก่อน

    i did the same exact things as in the video and the same code and when I try the AT commands but it doesnt work I have tried other BAUD rates and everything and I have tired HC-05 and HC-06 what should I do

    • @BytesNBits
      @BytesNBits  5 หลายเดือนก่อน

      That's a strange one. I'd go back to basics first. Check you've got the wiring correct. Check your resistors in the voltage divider are giving the right output voltage. Maybe swap them for a logic level converter. Make sure the sketch is using the right pin assignments. If this all checks out add a line in the Serial.available block to send the input character back to the serial terminal to check your key presses are getting through. If that's all Ok try sending actual commands to the BT module in code and see if it responds.

    • @tinkerer-fc3zv
      @tinkerer-fc3zv 2 หลายเดือนก่อน

      @@BytesNBits From my investigations today, I am guessing that the software serial port is too far off from 38400 baud to communicate with the HC-05 reliably. When I just sent AT, I could see on an oscilloscope that the HC-05 was responding with the correct bit sequence, but the Arduino was not correctly interpreting the bits.
      To test my hypothesis, I created the program below that uses the HW serial port. I used a cheap ~$10 logic analyzer and pulseview to view the data going in both directions. I could see that the HC-05 was replying properly. I put the 10 second wait at the start since I had to reattach the wires from pins 1 and 0 after downloading the code, and I also needed to start the logic analyzer capture after I started the program. I noticed that the HC-05 replied with an error code at the first "AT
      ", but it responded properly to the rest of the commands.
      For me, the software serial port did communicate correctly with the HC-05 at 9600 baud, but it garbled a few characters at 19200.
      #include "Arduino.h"
      void setup() {
      Serial.begin(38400);
      }
      void loop() {
      delay(10000);
      Serial.write("AT
      ");
      delay(50);
      Serial.write("AT+UART=19200,0,0
      ");
      delay(50);
      Serial.write("AT+UART?
      ");
      delay(100);
      Serial.write("AT
      ");
      while(1);
      }
      So, for the HC-05, if you only need to make infrequent changes like password, name, and baud rate, you could just use a program like the above to make the changes.

  • @bencypg
    @bencypg 3 ปีที่แล้ว

    Not able to set AT+POLAR,1,0 using USB to serial convertor. All other command works fine. Tried 3 different HC05 and also different USB to serial convertor but only this command does not work. Please help

    • @BytesNBits
      @BytesNBits  3 ปีที่แล้ว

      Hi. Try AT+POLAR=1,0. I think it needs an = rather than the first comma.

    • @bencypg
      @bencypg 3 ปีที่แล้ว

      @@BytesNBits right, my command is same as you said. Tried with upper case and lower case. No luck

    • @BytesNBits
      @BytesNBits  3 ปีที่แล้ว

      @@bencypg Does it respond to the polar query command - "AT+POLAR?"

    • @bencypg
      @bencypg 3 ปีที่แล้ว

      @@BytesNBits No.

    • @BytesNBits
      @BytesNBits  3 ปีที่แล้ว

      @@bencypg I'm not sure what to try next?? It looks like that command is just missing from the firmware on your devices. I only have HC06s here so can't confirm it. All the datasheets confirm the command should be there. Are all your devices from the same manufacturer? Is there a datasheet specifically from that supplier? Sorry I can't give you an answer.

  • @felipe_ramos
    @felipe_ramos 3 ปีที่แล้ว

    Do you know how to add service and characteristics ?

    • @BytesNBits
      @BytesNBits  3 ปีที่แล้ว +1

      Hi. You'd need to have a look the the data sheet for your device and see what commands or hardware setup options there are. I know the HC05 has more set up features but I tend to only use them as plug and play connections to a mobile phone.

    • @felipe_ramos
      @felipe_ramos 3 ปีที่แล้ว

      @@BytesNBits Hi. thanks for the reply. I'm working on a project which consists in send data to a hc-05 bluetooth module from a react native app. In the app, I'm using a react-native-ble-plx plugin to handle with bluetooth communication. But this plugin doesn't find the hc-05 module, I don't know why but, I presume tha this module doesn't work with BLE. And thats why I trying to setup a BLE service and characteristc. Maybe it's the reason to hc-05 never get found.
      I don't know if it's possible, but, thanks for the tip. I will look in the data sheet to see if find a solution.

    • @BytesNBits
      @BytesNBits  3 ปีที่แล้ว

      @@felipe_ramos Hi. The HC05 and HC06 are not BLE compatible. You'll need a different module. If you do a search on Amazon or eBay for 'ble module' you should find what you're looking for.

    • @felipe_ramos
      @felipe_ramos 3 ปีที่แล้ว +1

      @@BytesNBits I was already suspecting about that, but then I found a stack overflow post saying that this it's possible. I spent the whole weekend trying to do this, lol. Today, I was about to give up, and now that you say me this, definitly I will search for another module. thanks man, you earned a subscriber.

  • @junilojbwahab8899
    @junilojbwahab8899 ปีที่แล้ว

    I have the same problem as @MAGWITCH and i still dont know what to do.

    • @BytesNBits
      @BytesNBits  ปีที่แล้ว +1

      Hi. The HC-05 works differently to my HC-06. There should be a small button on the HC-05 unit. You need to hold this in as you turn on the power. This will put it into AT mode so it will talk to you. Set it up as you want and then power off and on again to get it back to normal mode. I hope this works!

  • @RetroEcoChicken
    @RetroEcoChicken ปีที่แล้ว +1

    Command Responce Result (AT Code for 06 bluetooth Moudle)
    AT+NAMExyz = OKsetname Sets the module name to “xyz”
    AT+PIN1234 = OKsetPIN Sets the module PIN to 1234
    AT+BAUD1 = OK1200 Sets the baud rate to 1200
    AT+BAUD2 = OK2400 Sets the baud rate to 2400

    • @BytesNBits
      @BytesNBits  ปีที่แล้ว

      Thanks for the codes.