Це відео не доступне.
Перепрошуємо.
Using AT Commands to Set Up Your Bluetooth Module : HC-05 and HC-06
Вставка
- Опубліковано 13 сер 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
This is a great tutorial. Very clear and easy to follow. Thanks heaps.
Glad it was helpful!
Thank you for your clear description of each step and its purpose
You are welcome!
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.
Hi. There's always a 'make it work' button that no one tells you about. Glad it helped.
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.
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!
@@BytesNBits thanks. Yes have tried everything. I'll just stick to to the hc06 as they work
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.
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?
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.
@@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.
@@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!
ua-cam.com/video/ykgt4v7_4y4/v-deo.html
Serial speed is by default 38400 in AT mode and you need to connect the key pin also on HC-05.
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?
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.
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
Thanks for the codes.
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.
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.
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
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.
@@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.
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?
If you've copied from the web page the top line has gotten corrupted by the editor
#include
should be
#include ;
How do you send data from the device to another device after you connected?
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.
I have the same problem as @MAGWITCH and i still dont know what to do.
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!
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
Hi. Try AT+POLAR=1,0. I think it needs an = rather than the first comma.
@@BytesNBits right, my command is same as you said. Tried with upper case and lower case. No luck
@@bencypg Does it respond to the polar query command - "AT+POLAR?"
@@BytesNBits No.
@@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.
Do you know how to add service and characteristics ?
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.
@@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.
@@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.
@@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.