UPDATES
September 4, 2013: Featured on Hackaday.com http://goo.gl/qxvWkd
September 1, 2013: Featured on DangerousPrototypes.com http://goo.gl/K4kH9g
INTRODUCTION
In this guide, I will explain how to use Arduino to change the settings of the ubiquitous HC-05 Bluetooth module using the AT command set. The HC-05 comes with a rich set of AT commands to perform various tasks such as changing the module's default settings including changing the pass code, the device name, and the baud rate. But the process of switching the HC-05 into AT command mode for first time users of the module is not straight forward and the docs takes short cuts. There are a couple of ways to do this. I have picked the one I think is the easiest I will do my best to illustrate the process in simple to follow steps. You can find the full set of AT commands in the attached datasheet.
BACKGROUND
In the process of using the HC-05 for a project, I ran into a situation where I needed to change the defaults for the module. For example, the default baud rate on the HC-05 is 9600. That's slow for high-speed transmission. The HC-05 can go as high as 1382400 baud rate according to the HC-05 reference. Also, the HC-05 has a default device name of HC-05. Having two or more of those devices in the same area can be confusing. You can use an AT command to change the device name. Also, the pin code default is 1234. You may wish to change that for some projects to ensure basic security.
After spending some time searching the web I realized many people are having a hard time changing the default settings for the HC-05. Switching the HC-05 from data transmission mode to configuration mode, to send AT commands to the HC-05, involves a few wiring and software acrobatics. Add to the mix all the variations of the HC Bluetooth module family and the various vendor settings and you get the picture.
This guide only covers the HC-05 module with the breakout board.
WARNING
The HC-05 is a 3.3V system but the breakout board offers current limiting resistors for some protection. While it's not advisable to keep the HC-05 connected to the 5V Arduino Uno pins, for this short exercise I decided to skip the voltage dividers which I use to drop 5V to 3.3V. I advise you to use voltage dividers whenever you connect the HC-05 pins to 5V pins such as the Arduino Uno. If you skip the voltage divider, do so at your own risk.
September 4, 2013: Featured on Hackaday.com http://goo.gl/qxvWkd
September 1, 2013: Featured on DangerousPrototypes.com http://goo.gl/K4kH9g
INTRODUCTION
In this guide, I will explain how to use Arduino to change the settings of the ubiquitous HC-05 Bluetooth module using the AT command set. The HC-05 comes with a rich set of AT commands to perform various tasks such as changing the module's default settings including changing the pass code, the device name, and the baud rate. But the process of switching the HC-05 into AT command mode for first time users of the module is not straight forward and the docs takes short cuts. There are a couple of ways to do this. I have picked the one I think is the easiest I will do my best to illustrate the process in simple to follow steps. You can find the full set of AT commands in the attached datasheet.
BACKGROUND
The HC-05 Bluetooth module and its siblings are by far the most popular
and inexpensive Bluetooth modules used for RF communications by
microcontroller hackers. It costs less than MYR 40.57 ( MYR 40.57 ( $10)) on ebay and
it's easy to implement. I have published two guides based on the HC-05
Bluetooth module. The first guide explains how to use the HC-05 with the Arduino. The second is an Android app that simplifies controlling Arduino from your smart phone over Bluetooth using the HC-05. In both cases, the default settings for the HC-05 were fine.
In the process of using the HC-05 for a project, I ran into a situation where I needed to change the defaults for the module. For example, the default baud rate on the HC-05 is 9600. That's slow for high-speed transmission. The HC-05 can go as high as 1382400 baud rate according to the HC-05 reference. Also, the HC-05 has a default device name of HC-05. Having two or more of those devices in the same area can be confusing. You can use an AT command to change the device name. Also, the pin code default is 1234. You may wish to change that for some projects to ensure basic security.
After spending some time searching the web I realized many people are having a hard time changing the default settings for the HC-05. Switching the HC-05 from data transmission mode to configuration mode, to send AT commands to the HC-05, involves a few wiring and software acrobatics. Add to the mix all the variations of the HC Bluetooth module family and the various vendor settings and you get the picture.
This guide only covers the HC-05 module with the breakout board.
WARNING
The HC-05 is a 3.3V system but the breakout board offers current limiting resistors for some protection. While it's not advisable to keep the HC-05 connected to the 5V Arduino Uno pins, for this short exercise I decided to skip the voltage dividers which I use to drop 5V to 3.3V. I advise you to use voltage dividers whenever you connect the HC-05 pins to 5V pins such as the Arduino Uno. If you skip the voltage divider, do so at your own risk.
Step 1: Components & Wiring
I have tested this guide with the following:
PARTS
PARTS
- HC-05 Bluetooth module (Bluetooth over serial)
- Arduino Uno R3
- Breadboard & jumper wires
- Arduino IDE
- HC-05 GND --- Arduino GND Pin
- HC-05 VCC (5V) --- Arduino 5V
- HC-05 TX --- Arduino Pin 10 (soft RX)
- HC-05 RX --- Arduino Pin11 (soft TX)
- HC-05 Key (PIN 34) --- Arduino Pin 9
Advertisement
Step 2: The Arduino Code for HC-05 Command Mode
This Arduino program (HC_05.ino) does two things. It takes the AT
commands you enter from the Arduino IDE Serial Monitor and sends those
commands to the HC-05. The program then reads the output of the HC-05
and displays it on the Arduino IDE Serial Monitor. You can also use a
terminal emulator such as Tera Term instead of the Arduino Serial
Monitor.
The Arduino communicates with the HC-05 using the SoftwareSerial ports while the Arduino communicates with the user via the Serial Monitor.
/*
AUTHOR: Hazim Bitar (techbitar)
DATE: Aug 29, 2013
LICENSE: Public domain (use at your own risk)
CONTACT: techbitar at gmail dot com (techbitar.com)
*/
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
void setup()
{
pinMode(9, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(9, HIGH);
Serial.begin(9600);
Serial.println("Enter AT commands:");
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTSerial.available())
Serial.write(BTSerial.read());
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.write(Serial.read());
}
The Arduino communicates with the HC-05 using the SoftwareSerial ports while the Arduino communicates with the user via the Serial Monitor.
/*
AUTHOR: Hazim Bitar (techbitar)
DATE: Aug 29, 2013
LICENSE: Public domain (use at your own risk)
CONTACT: techbitar at gmail dot com (techbitar.com)
*/
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
void setup()
{
pinMode(9, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(9, HIGH);
Serial.begin(9600);
Serial.println("Enter AT commands:");
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTSerial.available())
Serial.write(BTSerial.read());
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.write(Serial.read());
}
Step 3: Steps To Switch The HC-05 Into Command Mode
For the HC-05 module to switch to AT command mode, the HC-05 pin
34 (often referred to as the Key pin) needs to pulled HIGH but in a
certain order of events explained below. When the HC-05 enters the AT
command mode, it will communicate at 38400 baud rate. Follow these steps
in the stated order to switch to the HC-05 to AT command mode.
- Wire the HC-05 and Arduino Uno per instructions.
- BEFORE YOU CONNECT THE ARDUINO TO THE USB remove the VCC (power) red wire from the HC-05 so it's not getting any power from the Arduino. All other wires are still connected.
- Now connect the Arduino Uno to the USB cable extended from your PC.
- Make sure the HC-05 module is NOT PAIRED with any other Bluetooth device.
- Re-connect the Arduino Uno 5V wire to the HC-05's VCC (5V power) pin.
- The HC-05 LED will blink on and off at about 2 second intervals. Now the HC-05 is in AT command mode ready to accept commands to change configuration and settings.
- To test if everything is wired correctly, open the Serial Monitor from the Arduino IDE and type "AT" and click SEND. You should see an "OK"
- If you don't see an "OK" check your wiring.
Step 4: Example HC-05 AT Commands
You can send AT Commands to the HC-05 from the Arduino IDE Serial
Monitor while the Arduino is running the attached Arduino program.
I have listed a few popular AT commands that will change the HC-05 device name, pass code, and speed. You will find a full set of AT commands from the attached HC-05 reference PDF file.
(remove double quotes from AT command)
I have listed a few popular AT commands that will change the HC-05 device name, pass code, and speed. You will find a full set of AT commands from the attached HC-05 reference PDF file.
(remove double quotes from AT command)
- To return HC-05 to mfg. default settings: "AT+ORGL"
- To get version of your HC-05 enter: "AT+VERSION?"
- To change device name from the default HC-05 to let's say MYBLUE enter: "AT+NAME=MYBLUE"
- To change default security code from 1234 to 2987 enter: "AT+PSWD=2987"
- To change HC-05 baud rate from default 9600 to 115200, 1 stop bit, 0 parity enter: "AT+UART=115200,1,0"
jakubK27
a month ago
Hi, instead of your pinout I have:
state, rxd, txd, gnd, vcc, en
Is the "en" pin seme as "key" pin? The "state" and "en" pins haven't got pins to connect to breadboard (there are only 4 pins, but other 2 are marked amd seem like they're ready to be soldered to pins, they have holes).
Sorry for my english and thanks for answer!
state, rxd, txd, gnd, vcc, en
Is the "en" pin seme as "key" pin? The "state" and "en" pins haven't got pins to connect to breadboard (there are only 4 pins, but other 2 are marked amd seem like they're ready to be soldered to pins, they have holes).
Sorry for my english and thanks for answer!
22 days ago
u got output using that bluetooth module ?
12 days ago
when connected
tx-rx,rx-tx,gnd-gnd,vcc-5v, starts blinking. when trying to connect,
ligts without blinking. But phone says something like couldn´t connect
and bluetooth starts blinking again.
a month ago
Like on this picture: http://www.martyncurrey.com/wp-content/uploads/2014/10/HC-06_zs-040_01_1200.jpg
16 days ago
Hi, I'm working with the
arduino Due and SoftwareSerial doesn't work. I'm not that great with the
coding, so could you help me out?
7 months ago
I connected hc05 module with arduino uno board with connections as-
G
HC-05 GND --- Arduino GND Pin
HC-05 VCC (5V) --- Arduino 5V
HC-05 TX --- Arduino Pin 10 (soft RX)
HC-05 RX --- Arduino Pin11 (soft TX)
HC-05 Key (PIN 34) --- Arduino Pin 9
After connecting i m getting rapid blinking of led on hc 05 module but unable to connect with any app on ios neither AT command is getting any response on serial port.
Suggest how to connect hc05 with arduino uno and how to use it on ios mobile app
G
HC-05 GND --- Arduino GND Pin
HC-05 VCC (5V) --- Arduino 5V
HC-05 TX --- Arduino Pin 10 (soft RX)
HC-05 RX --- Arduino Pin11 (soft TX)
HC-05 Key (PIN 34) --- Arduino Pin 9
After connecting i m getting rapid blinking of led on hc 05 module but unable to connect with any app on ios neither AT command is getting any response on serial port.
Suggest how to connect hc05 with arduino uno and how to use it on ios mobile app
7 months ago
If it has a small button above
the EN/KEY/WAKE UP pin, disconnected Vcc, press and hold that button,
connect Vcc and it the LED in the module should blink slowly and allow
you to enter AT codes.
Regards,
Regards,
17 days ago
This worked for me too. Also,
after getting the LED to blink slowly, press the Reset button on the
Arduino. Exact steps that seem to always work:
1. Unplug power from HC-05
2. Upload sketch from this Instructable
3. Hold in HC-05 button
4. Reconnect power to HC-05 (wait until LED blinks slowly)
5. Press Arduino reset button
6. Open Serial Monitor
7. Make sure "Both NL & CR" is selected
8. Type AT commands
We had 3 people in a workshop this evening and when everyone followed this procedure it always worked.
1. Unplug power from HC-05
2. Upload sketch from this Instructable
3. Hold in HC-05 button
4. Reconnect power to HC-05 (wait until LED blinks slowly)
5. Press Arduino reset button
6. Open Serial Monitor
7. Make sure "Both NL & CR" is selected
8. Type AT commands
We had 3 people in a workshop this evening and when everyone followed this procedure it always worked.
6 months ago
that worked perfectly
thanks
thanks
6 months ago
pin 34 cannot be connected
directly to Arduino PIN 9, use level converter from 5 volts to 3.3 and
vice versa or simply use two 1 K ohm resistors between PIN 9 and VSS
and connect pin 34 inbetween
a month ago
that my be due to mismatch of buad rate
4 months ago
//Correction :
#include<SoftwareSerial.h>
SoftwareSerial BTSerial(10,11);
String HC05_Responce="";
void setup(){
pinMode(9,OUTPUT);
digitalWrite(9,HIGH);
Serial.begin(9600);
Serial.println("Enter AT command:");
BTSerial.begin(38400);
}
void loop(){
if(BTSerial.available())
Serial.write(BTSerial.read());
if(Serial.available())
BTSerial.write(Serial.read());
}
#include<SoftwareSerial.h>
SoftwareSerial BTSerial(10,11);
String HC05_Responce="";
void setup(){
pinMode(9,OUTPUT);
digitalWrite(9,HIGH);
Serial.begin(9600);
Serial.println("Enter AT command:");
BTSerial.begin(38400);
}
void loop(){
if(BTSerial.available())
Serial.write(BTSerial.read());
if(Serial.available())
BTSerial.write(Serial.read());
}
5 months ago
HELLO KJOHARI21
Instead of no line ending drop the menu down and select "Both NL & CR"
and try again.
cheers ;)
Instead of no line ending drop the menu down and select "Both NL & CR"
and try again.
cheers ;)
5 months ago
HiKjohari21, il think you have to select "both line feed and carriage return" in the serial monitor and it will work.
Regards.
Regards.
2 months ago
If there is anyone still
struggling out there, I made another instructable detailing how to use
this modules in master, and slave mode. It is meant to explain how to
get each model into AT mode, and then, to get them working with code.
http://www.instructables.com/id/Arduino-Bluetooth-Master-and-Slave-Using-Any-HC-05/
http://www.instructables.com/id/Arduino-Bluetooth-Master-and-Slave-Using-Any-HC-05/
3 months ago
Hello to everyone.I have make a
bleutooth robot which i can control it via android(tablet) and i have a
problem with the code.I want from the robot to stop when connection
lost or bluetooth disconnected.Now when the connection lost the robot go
ahead and falls on the objects.How to add this line on the code?Can you
help me please?The STATE pin of HC-05 when is HIGH is connected and
when is LOW is disconnected.I put this on my code but it doesn't
stop.Thank you for your time
The bluetooth that i use is HC-05
My code:
#include <Servo.h>
Servo SERVO_1; // Initialize Servo1
// Motor Control Variables
int PWM1 = 9;
int ENABLE1 = 8;
int PWM2 = 5;
int ENABLE2 = 7;
int PWM3 = 3;
int ENABLE3 = 4;
int PWM4 = 6;
int ENABLE4 = 12;
int STATE=2;
void setup() {
SERVO_1.attach(10);
Serial.begin(9600);
pinMode(ENABLE1, OUTPUT); //Δήλωση όλων των μεταβλητών ως έξοδος
pinMode(ENABLE2, OUTPUT); //Δήλωση όλων των μεταβλητών ως έξοδος
pinMode(ENABLE3, OUTPUT); //Δήλωση όλων των μεταβλητών ως έξοδος
pinMode(ENABLE4, OUTPUT); //Δήλωση όλων των μεταβλητών ως έξοδος
pinMode(STATE, INPUT);
}
void loop() {
if(digitalRead(STATE)== HIGH)
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
int incomingByte = Serial.read();
// action depending on the instruction
// as well as sending a confirmation back to the app
switch (incomingByte) {
case 'F':
moveForward();
Serial.println("Going forward");
break;
case 'L' : // Case 'L' is received,
SERVO_1.write (180); // Στρίψε Αριστερά.
SERVO_1.attach(10);
break;
case 'N':
turnright();
Serial.println("Turning right");
break;
case 'M':
turnleft();
Serial.println("Turning left");
break;
case 'O' : // Case 'L' is received,
SERVO_1.write (0); // Στρίψε Αριστερά.
SERVO_1.attach(10);
break;
case 'B':
moveBackward();
Serial.println("Going forward");
break;
case 'P':
SERVO_1.write(90); // Στρίψε Αριστερά.
SERVO_1.attach(10);
break;
case 'S':
moveNone();
Serial.println("Stopping");
break;
default:
// if nothing matches, do nothing
break;
}
}
}
void moveForward() {
// turn the driving motor on to go forwards at set speed
digitalWrite(ENABLE1, HIGH);
digitalWrite(ENABLE2, HIGH);
digitalWrite(ENABLE3, HIGH);
digitalWrite(ENABLE4, HIGH);
analogWrite(PWM1, 255);
analogWrite(PWM2, 255);
analogWrite(PWM3, 255);
analogWrite(PWM4, 255);
}
void moveBackward() {
// turn the driving motor on to go backwards at set speed
digitalWrite(ENABLE1, LOW);
digitalWrite(ENABLE2, LOW);
digitalWrite(ENABLE3, LOW);
digitalWrite(ENABLE4, LOW);
analogWrite(PWM1, 255);
analogWrite(PWM2, 255);
analogWrite(PWM3, 255);
analogWrite(PWM4, 255);
}
void turnright() {
digitalWrite(ENABLE1, HIGH);
digitalWrite(ENABLE2, HIGH);
digitalWrite(ENABLE3, LOW);
digitalWrite(ENABLE4, LOW);
analogWrite(PWM1, 255);
analogWrite(PWM2, 255);
analogWrite(PWM3, 255);
analogWrite(PWM4, 255);
}
void turnleft() {
digitalWrite(ENABLE1, LOW);
digitalWrite(ENABLE2, LOW);
digitalWrite(ENABLE3, HIGH);
digitalWrite(ENABLE4, HIGH);
analogWrite(PWM1, 255);
analogWrite(PWM2, 255);
analogWrite(PWM3, 255);
analogWrite(PWM4, 255);
}
void moveNone() {
// turn the driving motor off
digitalWrite(ENABLE1, 0);
digitalWrite(ENABLE2, 0);
digitalWrite(ENABLE3, 0);
digitalWrite(ENABLE4, 0);
analogWrite(PWM1, 0);
analogWrite(PWM2, 0);
analogWrite(PWM3, 0);
analogWrite(PWM4, 0);
SERVO_1.detach();
}
The bluetooth that i use is HC-05
My code:
#include <Servo.h>
Servo SERVO_1; // Initialize Servo1
// Motor Control Variables
int PWM1 = 9;
int ENABLE1 = 8;
int PWM2 = 5;
int ENABLE2 = 7;
int PWM3 = 3;
int ENABLE3 = 4;
int PWM4 = 6;
int ENABLE4 = 12;
int STATE=2;
void setup() {
SERVO_1.attach(10);
Serial.begin(9600);
pinMode(ENABLE1, OUTPUT); //Δήλωση όλων των μεταβλητών ως έξοδος
pinMode(ENABLE2, OUTPUT); //Δήλωση όλων των μεταβλητών ως έξοδος
pinMode(ENABLE3, OUTPUT); //Δήλωση όλων των μεταβλητών ως έξοδος
pinMode(ENABLE4, OUTPUT); //Δήλωση όλων των μεταβλητών ως έξοδος
pinMode(STATE, INPUT);
}
void loop() {
if(digitalRead(STATE)== HIGH)
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
int incomingByte = Serial.read();
// action depending on the instruction
// as well as sending a confirmation back to the app
switch (incomingByte) {
case 'F':
moveForward();
Serial.println("Going forward");
break;
case 'L' : // Case 'L' is received,
SERVO_1.write (180); // Στρίψε Αριστερά.
SERVO_1.attach(10);
break;
case 'N':
turnright();
Serial.println("Turning right");
break;
case 'M':
turnleft();
Serial.println("Turning left");
break;
case 'O' : // Case 'L' is received,
SERVO_1.write (0); // Στρίψε Αριστερά.
SERVO_1.attach(10);
break;
case 'B':
moveBackward();
Serial.println("Going forward");
break;
case 'P':
SERVO_1.write(90); // Στρίψε Αριστερά.
SERVO_1.attach(10);
break;
case 'S':
moveNone();
Serial.println("Stopping");
break;
default:
// if nothing matches, do nothing
break;
}
}
}
void moveForward() {
// turn the driving motor on to go forwards at set speed
digitalWrite(ENABLE1, HIGH);
digitalWrite(ENABLE2, HIGH);
digitalWrite(ENABLE3, HIGH);
digitalWrite(ENABLE4, HIGH);
analogWrite(PWM1, 255);
analogWrite(PWM2, 255);
analogWrite(PWM3, 255);
analogWrite(PWM4, 255);
}
void moveBackward() {
// turn the driving motor on to go backwards at set speed
digitalWrite(ENABLE1, LOW);
digitalWrite(ENABLE2, LOW);
digitalWrite(ENABLE3, LOW);
digitalWrite(ENABLE4, LOW);
analogWrite(PWM1, 255);
analogWrite(PWM2, 255);
analogWrite(PWM3, 255);
analogWrite(PWM4, 255);
}
void turnright() {
digitalWrite(ENABLE1, HIGH);
digitalWrite(ENABLE2, HIGH);
digitalWrite(ENABLE3, LOW);
digitalWrite(ENABLE4, LOW);
analogWrite(PWM1, 255);
analogWrite(PWM2, 255);
analogWrite(PWM3, 255);
analogWrite(PWM4, 255);
}
void turnleft() {
digitalWrite(ENABLE1, LOW);
digitalWrite(ENABLE2, LOW);
digitalWrite(ENABLE3, HIGH);
digitalWrite(ENABLE4, HIGH);
analogWrite(PWM1, 255);
analogWrite(PWM2, 255);
analogWrite(PWM3, 255);
analogWrite(PWM4, 255);
}
void moveNone() {
// turn the driving motor off
digitalWrite(ENABLE1, 0);
digitalWrite(ENABLE2, 0);
digitalWrite(ENABLE3, 0);
digitalWrite(ENABLE4, 0);
analogWrite(PWM1, 0);
analogWrite(PWM2, 0);
analogWrite(PWM3, 0);
analogWrite(PWM4, 0);
SERVO_1.detach();
}
4 months ago
I'm encountering a problem :
I've plug my HC-05 through arduino uno, on the serial monitor it say "ready for AT commands".
Then i wrote "AT" in the monitor but no OK answer
What Should I do ??
Thanks
I've plug my HC-05 through arduino uno, on the serial monitor it say "ready for AT commands".
Then i wrote "AT" in the monitor but no OK answer
What Should I do ??
Thanks
4 months ago
IM HAVING THE SAME PROBLEM
4 months ago
i want to connect HC 05 with RX65N (100 pin). i made pin 34 high HC 05 entering in command mode but it is not responding back
which register has to be connected between vcc and pin34
which register has to be connected between vcc and pin34
5 months ago
My HC-05 is already blinking
slowly (every 2s), but when I send 'AT' from serial monitor, I get
nothing. I use the same code in this instructable. Someone, please help
me.
5 months ago
What should I do if I receive some unreadable character
Plzz reply
Plzz reply
6 months ago
hi I just have to get data from the pin 7 of Arduino do I need to configure the hc05 ?
plzz help me the coding too
plzz help me the coding too
6 months ago
do i have to change the default AT setting on bluetooth to make it work with my android
6 months ago
hi there
can we connect more than 4 hc-05 in slave and one hc-05 module in master
can we connect more than 4 hc-05 in slave and one hc-05 module in master
6 months ago
Hi, thank you for this instractable...
I am very glad to explore HC05 Bluetooth.
my HC05 module doesn't have a connection to the KEY pin instead I have an ENABLE pin and a small tactile switch that is not connected to any pin.
so; I took a wire from pin 34 and put it in-between two serially connected 1 K Ohm resistors between PIN 9 " Arduino" and VSS.
put 3 new lines in the Arduino sketch and my sketch is as follow:
///////////////
#include "SoftwareSerial.h"
SoftwareSerial BTSerial(10, 11);
void setup() {
pinMode(8, OUTPUT); digitalWrite(8, LOW);
// connected to the VCC of the Bluetooth module
pinMode(9, OUTPUT); digitalWrite(9, HIGH);
Serial.begin(9600);
delay(1000);
Serial.println("Enter AT command mode");
digitalWrite(8, HIGH);
BTSerial.begin(38400);
}
void loop() {
if (BTSerial.available()) Serial.write(BTSerial.read());
if (Serial.available()) BTSerial.write(Serial.read());
}
/////////////////
I have one idea for this instractable; that is not to play with the wire manually; instead let Arduino do the connection for you...
and this work very well every time i upload a new sketch
I am very glad to explore HC05 Bluetooth.
my HC05 module doesn't have a connection to the KEY pin instead I have an ENABLE pin and a small tactile switch that is not connected to any pin.
so; I took a wire from pin 34 and put it in-between two serially connected 1 K Ohm resistors between PIN 9 " Arduino" and VSS.
put 3 new lines in the Arduino sketch and my sketch is as follow:
///////////////
#include "SoftwareSerial.h"
SoftwareSerial BTSerial(10, 11);
void setup() {
pinMode(8, OUTPUT); digitalWrite(8, LOW);
// connected to the VCC of the Bluetooth module
pinMode(9, OUTPUT); digitalWrite(9, HIGH);
Serial.begin(9600);
delay(1000);
Serial.println("Enter AT command mode");
digitalWrite(8, HIGH);
BTSerial.begin(38400);
}
void loop() {
if (BTSerial.available()) Serial.write(BTSerial.read());
if (Serial.available()) BTSerial.write(Serial.read());
}
/////////////////
I have one idea for this instractable; that is not to play with the wire manually; instead let Arduino do the connection for you...
and this work very well every time i upload a new sketch
7 months ago
can anyone please tell me how can i change data rate in Hc-05?
and how to change the class of device? what will happen if i change the class? whether it would affect the data rate or something?
and how to change the class of device? what will happen if i change the class? whether it would affect the data rate or something?
7 months ago
AT+CLASS=<Param>
a year ago
can u please tell me how to change my pin or password for my hc-05??
7 months ago
To show your password do AT+ PSWD?
And to have it changed do AT+PSWD=<Param>
Regards,
And to have it changed do AT+PSWD=<Param>
Regards,
7 months ago
To show your password do AT+ PSWD?
And to have it changed do AT+PSWD=<Param>
Regards,
And to have it changed do AT+PSWD=<Param>
Regards,
7 months ago
To show your password do AT+ PSWD?
And to have it changed do AT+PSWD=<Param>
Regards,
And to have it changed do AT+PSWD=<Param>
Regards,
7 months ago
To show your password do AT+ PSWD?
And to have it changed do AT+PSWD=<Param>
Regards,
And to have it changed do AT+PSWD=<Param>
Regards,
7 months ago
Connect Hc-05 to the Serial
Monitor. then Convert the HC-05 into AT command mode. then type AT+PSWD?
then press enter button(\r\n). it will reply PSWD="XXXX", then Put
AT+PSWD=password. then password will set as a password.
8 months ago
Once it is in full AT mode send
"AT+PSWD=0000" (without quotes) and don't forget to be sending the
Newline and Carriage return characters after each command...
7 months ago
hi, if u having trouble in
making into AT mode of HC-05 (ZS-040)(especiall if one having en/wakeup
up pin instead of key pin). Follow they bellow procedure
Power off HC-05 module.
Press and hold small button above EN pin.
Power on and keep pressing small button.
Small LED should start to blink slowly about once every 2 seconds.
for more info visit below site:
http://abratukhin.blogspot.in/2015/04/connect-atmega328-with-hc-05-zs-040.html
Power off HC-05 module.
Press and hold small button above EN pin.
Power on and keep pressing small button.
Small LED should start to blink slowly about once every 2 seconds.
for more info visit below site:
http://abratukhin.blogspot.in/2015/04/connect-atmega328-with-hc-05-zs-040.html
7 months ago
Hi, what should I do if I don't have a button above the EN pin?
7 months ago
hi, if u having trouble in
making into AT mode of HC-05 (ZS-040)(especiall if one having en/wakeup
up pin instead of key pin). Follow they bellow procedure
Power off HC-05 module.
Press and hold small button above EN pin.
Power on and keep pressing small button.
Small LED should start to blink slowly about once every 2 seconds.
for more info visit below site:
http://abratukhin.blogspot.in/2015/04/connect-atmega328-with-hc-05-zs-040.html
Power off HC-05 module.
Press and hold small button above EN pin.
Power on and keep pressing small button.
Small LED should start to blink slowly about once every 2 seconds.
for more info visit below site:
http://abratukhin.blogspot.in/2015/04/connect-atmega328-with-hc-05-zs-040.html
a year ago
I have followed this tutorial
and others on the internet and am getting the board into AT mode and my
board is responding however it is responding in absolute gibberish for
example I type AT with both NL & CR on and a baud rate of 9600 on
the serial monitor and I get result of ϧ†…ÿ or some other variation of
the same code I have tried and tested playing around with different baud
rates I have several different hc-05 they all give me the same I have
connected the RX, TX in the schematic the way it is labelled and
reversed and I am still getting no luck can anyone give me some helpful
information I don't have ausb ttl converter and would prefer not to wait
for one, any help would be appreciated.
Thanks in advance, Chris.
Thanks in advance, Chris.
8 months ago
Hi, the fix for this is to put
the module into AT mode with the user-defined baud rate, which by
default is 9600. To do this, pull pin 34 high AFTER power-up instead of
before. You won't have any indication of the mode change, i.e the led
will continue blinking quickly whereas in the 38400 baud AT mode the led
starts blinking slowly, on 2s, off 2s. I have posted an answer with
code + additional info at
http://forum.arduino.cc/index.php?topic=302827.msg2561221#msg2561221
8 months ago
Thank you for the link. After
reading some of the suggestions I was able to get my HC-05 into AT mode
just by holding the button while powering on. The LED went to the long
blink and all AT commands functioned properly.
a year ago
I am getting the same thing.
Instead of the "OK" response I get "ϧ
" plus two unprintable
characters. Sending commands seems to work but I never really know since
I don't get an understandable response.
9 months ago
i had try it but in serial monitor shows like xxxxxxx€ø.
also i had change all baud rates nothing happens.. im using hc-05
also i had change all baud rates nothing happens.. im using hc-05
9 months ago
hi there, i paired up 2 hc05 master "1" and slave "0" doing this
AT commands
//SLAVE = 98d3:31:2093cb AT+ROLE=0
//MASTER= 98d3:32:204d2a AT+ROLE=1
//AT+BIND=98d3,31,2093cb
//AT+BIND=98d3,32,204d2a
The end im left with paired modules that can talk to one another now i set this in AT+UART=9600.0.0 or 38400,0,0 im not sure now but it worked out fine now in the sketch i was doing all this in terminal obvsly using the terminal baud rate which was
as follow
include SoftwareSerial.h
SoftwareSerial mySerial(10, 11); RX, TX
void setup
{ Serial.begin(38400);
pinMode(9, OUTPUT);
digitalWrite(9, HIGH);
Serial.println("Enter AT commands:");
mySerial.begin(38400);
}
so my problem is that when i try to take the 2 talking modules to use in another project im not sure but they dont communicate no more "after uploading new sketch" am i suppose to use the same baud rate as in the sketch (38400); or should i be using the baud that i set this 2 up to begin with when i did the whole AT+UART=9600.0.0 or 38400,0,0 ???
i was assuming what i have now when they were talking was a wireless RS232/terminal right? if so then all i have to do is make sure in the loop of what ever other program i go to use this modules on that they talk to that SoftwareSerial mySerial or something like this
void loop()
{
if (mySerial.available())
mySerial.write("Variable or Array here");
AT commands
//SLAVE = 98d3:31:2093cb AT+ROLE=0
//MASTER= 98d3:32:204d2a AT+ROLE=1
//AT+BIND=98d3,31,2093cb
//AT+BIND=98d3,32,204d2a
The end im left with paired modules that can talk to one another now i set this in AT+UART=9600.0.0 or 38400,0,0 im not sure now but it worked out fine now in the sketch i was doing all this in terminal obvsly using the terminal baud rate which was
as follow
include SoftwareSerial.h
SoftwareSerial mySerial(10, 11); RX, TX
void setup
{ Serial.begin(38400);
pinMode(9, OUTPUT);
digitalWrite(9, HIGH);
Serial.println("Enter AT commands:");
mySerial.begin(38400);
}
so my problem is that when i try to take the 2 talking modules to use in another project im not sure but they dont communicate no more "after uploading new sketch" am i suppose to use the same baud rate as in the sketch (38400); or should i be using the baud that i set this 2 up to begin with when i did the whole AT+UART=9600.0.0 or 38400,0,0 ???
i was assuming what i have now when they were talking was a wireless RS232/terminal right? if so then all i have to do is make sure in the loop of what ever other program i go to use this modules on that they talk to that SoftwareSerial mySerial or something like this
void loop()
{
if (mySerial.available())
mySerial.write("Variable or Array here");
10 months ago
didnt had success with this
setup. Seems like I couldnt work out the right combination of baud rate
and return characters (which are 38400 and cr+lf for my cz-hc-05).
However, I hooked up the hc-05 directly to my usb ftdi dongle and it
worked perfectly with a random serial terminal program. (had a 3.3
voltage regulator for the key pin but dont know if thats necessary).
2 years ago
Dear Hazim, thank you for this
very useful application. I have an EN pin instead of KEY pin on my HC05
and it does not seem to be connected to PIO11 (Pin34) (I have checked it
with an AVO. Do you think short circuiting the EN pin with Pin34 will
solve the problem?
My second question is, how can I pair the HC05 connected to an Arduino uno with an HC06 connected to an ATTiny 85?
Cheers.
My second question is, how can I pair the HC05 connected to an Arduino uno with an HC06 connected to an ATTiny 85?
Cheers.
10 months ago
:D I always wonder about that button
a year ago
Hello!
Everybody who is not able to get into AT-mode with this Tutorial should check if they have a HC-05 (ZS-040) Bluetooth Module. If so, check out Martyn Currey's tutorial: http://www.martyncurrey.com/arduino-with-hc-05-blu... With this tutorial I was finally able to access AT-mode :-D.
Everybody who is not able to get into AT-mode with this Tutorial should check if they have a HC-05 (ZS-040) Bluetooth Module. If so, check out Martyn Currey's tutorial: http://www.martyncurrey.com/arduino-with-hc-05-blu... With this tutorial I was finally able to access AT-mode :-D.
a year ago
hi, you can my older post
Wakeup pin is a pin that works for you configure the AT-Command setting, the previous post I already give an example and program.
[ HC-05 ] ___________ [ ARDUINO ]
vcc ------------------------- pin7(Arduino)
gnd ------------------------ gnd (Arduino)
txd ------------------------- pinA0 (Arduino)
rxd ------------------------- pinA1 (Arduino)
wakeup/ en/ key ------ pin8 (Arduino)
Wakeup pin is a pin that works for you configure the AT-Command setting, the previous post I already give an example and program.
[ HC-05 ] ___________ [ ARDUINO ]
vcc ------------------------- pin7(Arduino)
gnd ------------------------ gnd (Arduino)
txd ------------------------- pinA0 (Arduino)
rxd ------------------------- pinA1 (Arduino)
wakeup/ en/ key ------ pin8 (Arduino)
a year ago
I tried using an HC-05 module with Putty on my windows 8 PC. When I
hit enter on a command I get the response I expect, but it repeats
indefinitely until I hit another key. I switched to Terraterm and that
program doesn't have the same problem. Any idea what is going on? I can
use Teraterm for the time being, but I'd like to know what is up with
Putty so I can trust it for other projects.
hit enter on a command I get the response I expect, but it repeats
indefinitely until I hit another key. I switched to Terraterm and that
program doesn't have the same problem. Any idea what is going on? I can
use Teraterm for the time being, but I'd like to know what is up with
Putty so I can trust it for other projects.
a year ago
I switched to another terminal
program, Terraterm and it worked better. But when I try to talk to it
from a Raspberry Pi using the same USB dongle it doesn't work at all. I
find this very frustrating. Sometimes it works, sometimes it doesn't
and the way it fails to work is very different. I've tried two
different modules which give the same results.
Ultimately I want to control this device from a small, MCU eval board. Before I do that I want to be able to control it from my computers using a terminal emulator.
Ultimately I want to control this device from a small, MCU eval board. Before I do that I want to be able to control it from my computers using a terminal emulator.
a year ago
hii,,
Because not all of hc-05 can be configured, I recommend you use the HC-05 as it is drawn.
Follow the instructions and programs,
Because not all of hc-05 can be configured, I recommend you use the HC-05 as it is drawn.
Follow the instructions and programs,
a year ago
Hi TheKoobay,
orang indonesia?
yes i am!
so it did works with my configuration. i'm using hyperterminal instead of Serial Monitor in Arduino. Finally i got the AT+BTRSSI value in slave mode, but not in master mode. In master mode (FB155BC), i can't connect it with my smartphone.
So know i'm working on it.
Regards
orang indonesia?
yes i am!
so it did works with my configuration. i'm using hyperterminal instead of Serial Monitor in Arduino. Finally i got the AT+BTRSSI value in slave mode, but not in master mode. In master mode (FB155BC), i can't connect it with my smartphone.
So know i'm working on it.
Regards
a year ago
To all receiving nothing when typing "AT":
I had the same issue but then I tried to type "AT+RESET" (no response but led started blinking faster) and then I checked SoftwareSerial library documentation and I used wrong pin for Rx on my Leonardo. Pin you use for receiving has to support change interrupts. Check documentation: http://arduino.cc/en/Reference/softwareSerial for more informations.
I had the same issue but then I tried to type "AT+RESET" (no response but led started blinking faster) and then I checked SoftwareSerial library documentation and I used wrong pin for Rx on my Leonardo. Pin you use for receiving has to support change interrupts. Check documentation: http://arduino.cc/en/Reference/softwareSerial for more informations.
2 years ago
Hi, very usefull ible.
I have one question. Is it possible to configure the HC-05 through AT commands to be seen as a keyboard/gamepad/mouse? According to the command ref pdf (appendix 2) you posted, there is such functionality. The question is if this would sufice, or a firmare flashing would be needed for it.
I have one question. Is it possible to configure the HC-05 through AT commands to be seen as a keyboard/gamepad/mouse? According to the command ref pdf (appendix 2) you posted, there is such functionality. The question is if this would sufice, or a firmare flashing would be needed for it.
2 years ago
Hello,
I have a CZ-HC-05 Bluetooth module that I've wired to an Arduino UNO Rev3 per the instructions on this website. I have successfully gotten the LED to blink slowly (2 seconds on, 2 seconds off) indicating to me that I'm in AT command mode. However, when I open the serial monitor and type AT I don't get an OK response from the HC-05. I copied and pasted the code from this website into the Arduino IDE so I'm certain it's correct. My serial monitor is set to 9600 to match the serial port baud rate. I also set the serial port to Both NL & CR. I have tried typing AT\n\r as well and still no response from the HC-05. Can anyone help me?
I have a CZ-HC-05 Bluetooth module that I've wired to an Arduino UNO Rev3 per the instructions on this website. I have successfully gotten the LED to blink slowly (2 seconds on, 2 seconds off) indicating to me that I'm in AT command mode. However, when I open the serial monitor and type AT I don't get an OK response from the HC-05. I copied and pasted the code from this website into the Arduino IDE so I'm certain it's correct. My serial monitor is set to 9600 to match the serial port baud rate. I also set the serial port to Both NL & CR. I have tried typing AT\n\r as well and still no response from the HC-05. Can anyone help me?
2 years ago
Hi, i have a question and i
hope you guys can help me with this. how does the arduino actually know
actually know which data it is going to send or receive? in which part
of the code does it do that? i want to make two arduinos one having a
HC05 as a master sending data over to a HC06 slave on two different
laptops. I hope you can answer me.
2 years ago
I have already configured my
HC-05 as a master. I would like to communicate it with an android app
where in this app will be used as the slave. I followed the instruction
wherein i configured it at master using AT command. I would like to test
if I can send data using HC-05 to android app so i run the program with
the same code including BTSerial.write("test") at the last if statement
hoping this data willl be send to my app, but it fail to do so. What
can I do to test it? Thanks
2 years ago
Had the same problem today, look at for nice tutorial.
(keep in mind those options in serial monitor in arduino ide)
http://arduinofy.blogspot.com.au/2013/10/tutorial-...
Also it seems that my module communicates ok both ways while in AT mode, and when in normal mode it only sends data to phone. the data i send from phone gets lost some ware, strange.. same issues anyone?
(keep in mind those options in serial monitor in arduino ide)
http://arduinofy.blogspot.com.au/2013/10/tutorial-...
Also it seems that my module communicates ok both ways while in AT mode, and when in normal mode it only sends data to phone. the data i send from phone gets lost some ware, strange.. same issues anyone?
2 years ago
I've chimed in late. Does "finish the command..." deal with the differences needed for HC-06? Are you saying that 6 days asadsalehhayat is using a HC-06 and not a HC-05? Other than the terminator, is dealing with a HC-06 the same as a HC-05? Thanks...