In this illustration we will going to wire the HC05 XBEE like Bluetooth Module, This Bluetooth module adapt the XBEE design compact communication, it has the pinout that compatible with the XBEE shields all kinds of microcontroller system, who uses 3.3v power out. This module uses AT command to set the baud rate. This module has integrates an onboard antenna that provides better signal quality transparent serial port which works with a variety of Bluetooth adapter and Bluetooth phones and pc. This module has been tested will all Bluetooth adapter on the market matching to use. Including laptops and mobile phones.
The HC03/05 is a compact Bluetooth Module, It uses CSR Bluetooth 04 External single chip Bluetooth System with CMOS technology and AFH (Adaptive Frequency Hopping). The HC02/05 module can be used with any host with an UART interface powered at 3.3v such as PIC, AVT, Arduino including Raspberry Pi, Bagel Bone any popular microcontroller and packet size open source pc.
This module has two modes of operation. AT Command mode to configure the Bluetooth control parameters and data communication mode to communication with other devices. The HC05 have 3 works roles a MASTER, SLAVE and LOOPBACK in data communication mode.
As the manufacturer release the item it is configured in transparent mode. So there is no command required for normal operation. The module is a replacement for wired serial connections, transparent usage. You can use it simply for serial port replacement to stablish connection between the MCU and GPS, PC to your embedded project and robotics, etc. Any serial stream from 9600 to 460800 bps can be passed seamlessly from your PC/PDA/MOBILE PHONES goes to your target devices.
The module also has two modes of operation namely AT command more and Data Communication Mode.
• AT command mode, you can configure in different control parameters which finally determine the working of the module. This mode you cannot communicate to other devices.
• The Data Communication Mode, you can drive this device as per the settings previously defined by the user in AT command mode and can communicate to other devices.
Device Specifications
• Speed: Asynchronous: 2.1Mbps(Max) / 160 kbps, Synchronous: 1Mbps/1Mbps
• Security: Authentication and encryption
• Typical -80dBm sensitivity
• Up to +4dBm RF transmit power
• Default Baud rate: 38400
• Data bits:8, Stop bit:1,Parity:No parity
• Supported baud rates: 9600, 19200, 38400, 57600, 115200, 230400 and 460800.
• Auto-connect to the last device on power as default.
• Auto-pairing PINCODE:”0000” as default
• Pairing PINCODE:”1234”as default
Led Indication / Status
• Power LED: When the module is powered, Blue LED will glow.
• Status LED: Indicates status of the module.
i. AT Mode (LED blinks once a second): When the module is powered and PIN34 (Key) is given high level, Status LED flickers slowly once a second. It indicates that the module is in AT mode, and the baud rate is 38400.
ii. Unpaired Mode (LED blinks two times a second): When the module is powered and PIN34 (Key) is given low level or floating, Status LED flickers quickly indicating that the module is in pair-able mode.
iii. Paired Mode (LED double flicker per second): Pairing is finished and module can communicate.
• Pair LED: Glows when connection is established with another Bluetooth module.
Software Required
Wiring Bluetooth Bee/XBEE Type Module with UART Bridge / Enabling AT-COMMAND
Wiring to Arduino Micro controller
The P-IO-11/Pin-19 & 20 KEY is for mode selection, by default the module is in AT COMMAND MODE and the default baud rate is 38400, on this mode you can change the Bluetooth Name, Baud Rate, Pass Key, and Master and Slave or Auto Connect Etc.
Getting to AT Mode
1. Open the key pin to give 3.3v to P-IO-11 / Connect the KEY Pin to 3.3v
2. Supply power to the module
3. Type AT Command from the CollTerm / Arduino IDE Serial Monitor at baud rate NL/CR – 38400
4. Reboot
Changing the device function
AT+ NAME? (Getting the name of the device)
AT+NAME=14CORE-BL-SLAVE (Naming for slave option)
AT+NAME=14CORE-BL-MASTER (Naming for master option)
Changing the device role
AT+ROLE=0 (To set as a slave option)
AT+ROLE=1 (To set as a master option)
Changing the password
The password by default is 12345. Confirm with AT+PSWD?
Connecting the two Bluetooth device
By connecting the device you should know the address to make it pair with another.
AT+ADDR?
Default address will show 14:2:11007
When using the address on AT command you should replace the color with a comma 14,2,110007
Reboot and remove the KEY connection which is connected to 3.3v
Getting Communication Mode
1. Short the key pin to give ground to P-IO-11
2. Supply power to the module
Sketch Test Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
/* 14CORE TEST CODE FOR BLUETOOTH MODULE SETTING UP AS MASTER or SLAVE MODE http://www.14core.com */ #include <NewSoftSerial.h> // Software Serial Port D2 and D3 #define RxD 2 //Optional if you want to used software serial #define TxD 3 //Optional if you want to used software serial NewSoftSerial blueToothSerial(RxD,TxD); void setup() { Serial.begin(9600); //Serial port for debugging, pinMode(RxD, INPUT); pinMode(TxD, OUTPUT); setupBlueToothConnection(); } void loop() { if(blueToothSerial.read() == 'a') { blueToothSerial.println("You are connected to Bluetooth Bee"); //You can write you BT communication logic here } } void setupBlueToothConnection() { Serial.print("14CORE BLuetooth XBEE Test Code"); Serial.print("Setting up Bluetooth link"); //For debugging, Comment this line if not required blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400 delay(1000); sendBlueToothCommand("\r\n+STWMOD=0\r\n"); // Set as Slave Mode sendBlueToothCommand("\r\n+STNA=14CORE-MASTER-BL\r\n"); sendBlueToothCommand("\r\n+STAUTO=0\r\n"); //Close the function sendBlueToothCommand("\r\n+STOAUT=1\r\n"); //Open the function sendBlueToothCommand("\r\n+STPIN=0000\r\n"); //Set pin code 0000 delay(2000); // This delay is required. blueToothSerial.print("\r\n+INQ=1\r\n"); delay(2000); // This delay is required. Serial.print("Setup complete"); } void sendBlueToothCommand(char command[]) { char a; blueToothSerial.print(command); Serial.print(command); delay(3000); while(blueToothSerial.available()) { Serial.print(char(blueToothSerial.read())); } } |
Download Bluetooth Serial Instruction Manual | PDF
Download Bluetooth HC02/05 AT Command Manual | PDF