The HC-05 Bluetooth module empowers your Arduino projects with wireless communication. This tutorial will guide you through connecting and using the HC-05 to establish a Bluetooth connection between your Arduino and a smartphone or other Bluetooth device.
Specifications:
- Bluetooth Version: Typically Bluetooth 2.0 with Enhanced Data Rate (EDR)
- Operating Voltage: 3.6V to 6V (be cautious, some sources recommend using a 3.3V source to avoid damaging the module)
- Logic Level: 3.3V (important to consider when connecting to 5V microcontrollers like Arduino Uno)
- Communication Interface: UART (Serial TTL)
- Operating Frequency: 2.4 GHz ISM band
- Range: Approximately 10 meters (or 33 feet) in open air (can be affected by walls and interference)
- Power Consumption: In active mode: around 30mA; In sleep mode: around 1mA
- Dimensions: Varies depending on the manufacturer, but typically around 2.6cm x 1.3cm x 0.2cm
PINOUT
- Enable / Key (Pin 1):
- This pin is used to toggle between Data Mode (set low) and AT command mode (set high). By default, it operates in Data mode.
- Vcc (Pin 2):
- Connect this pin to the +5V supply voltage on your Arduino.
- Ground (Pin 3):
- Connect this pin to the system ground.
- TX (Transmitter, Pin 4):
- Transmits serial data. Anything received via Bluetooth will be given out by this pin as serial data.
- RX (Receiver, Pin 5):
- Receives serial data. Any serial data given to this pin will be broadcasted via Bluetooth.
- State (Pin 6):
- This pin is connected to an onboard LED. It can be used as feedback to check if the Bluetooth module is working properly.
LED :
-
- Indicates the status of the module.
- LED status indications:
- Blink once every 2 seconds: Module has entered Command Mode.
- Repeated blinking: Waiting for connection in Data Mode.
- Blink twice every 1 second: Connection successful in Data Mode.
Button :
-
- Used to control the Key/Enable pin, toggling between Data and Command Mode
-
- The button (also known as the KEY pin) is used to control the behavior of the HC-05 module.
- When you press the button, it toggles the module between two modes:
- Data Mode: By default, the HC-05 operates in Data Mode. In this mode, it communicates with other devices (such as an Arduino) via serial communication (TX and RX pins).
- AT Command Mode: When you press and hold the button while powering up the module (or shortly after), it enters AT Command Mode. In this mode, you can send AT commands to configure various settings of the HC-05 module (such as changing its name, pairing code, baud rate, etc.).
- AT Command Mode allows you to customize the behavior of the module according to your project requirements.
Remember that the button (KEY pin) is essential for configuring the HC-05 module. By entering AT Command Mode, you can set parameters and adjust its behavior. If you’re planning to change settings or pair the module with specific devices, you’ll need to use this button to access the command mode.
Renaming the HC-05
Learn how to rename your HC-05 module (put it in command mode):
Disconnect the Arduino Uno from computer. Then connect the Bluetooth Module to Arduino Uno with the Female to Male jumber wire.
Connection
Arduino Uno – Bluetooth Module
3V3 – > 5V
GND -> GND
Tx -> Tx
Rx -> Rx
3V3 -> EN
- There is a pushbutton near to the EN pin of Bluetooth Module. Press that button and hold. Then connect the Arduino Uno to computer. Then release the button.
- Then the LED on the Bluetooth Module start blinking with the inter well of 2 seconds. This indicates now the Bluetooth Module in command mode.
- Next open the serial monitor on Arduino Uno. And set the baud rate as
38400
and set output mode to “Both NL & CR
“ - Here we use the AT commands. First type AT on the serial monitor and press send. You will see a
OK
message when everything is fine. - Type
AT+NAME=name
and press Send. It will return aOK
message. - Type
AT+PSWD="XXXX"
and press Send XXXX is the new code
Arduino Uno
Bluetooth HC-05 Module
LED
Cables
Turn on an LED or activate a relay using an Arduino and a Bluetooth module. Use an application that i built using MIT App Inventor
With this application, you can turn on an LED or activate a relay using an Arduino and a Bluetooth module. The application sends a character to the Arduino microprocessor when a button is pressed.
You can turn on the LED using the left side of the screen, the on/off button, or you can use the toggle button on the right.
Download the App from Play Store using the link or use the download button
char Incoming_value = 0; //Variable for storing Incoming_value void setup() { Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission pinMode(13, OUTPUT); //Sets digital pin 13 as output pin } void loop() { if(Serial.available() > 0) { Incoming_value = Serial.read(); //Read the incoming data and store it into variable Incoming_value Serial.print(Incoming_value); //Print Value of Incoming_value in Serial monitor Serial.print("\n"); //New line if(Incoming_value == 'H') //Checks whether value of Incoming_value is equal to H digitalWrite(13, HIGH); //If value is 1 then LED turns ON else if(Incoming_value == 'L') //Checks whether value of Incoming_value is equal to L digitalWrite(13, LOW); //If value is 0 then LED turns OFF } }