AN INTRODUCTION TO BLUETOOTH MODULES (HC-05 & HC-06)

Similar documents
Bluetooth HC-06 with serial port module Easy guide

Bluetooth to Serial Adapter

Arduino Wifi shield And reciever. 5V adapter. Connecting wifi module on shield: Make sure the wifi unit is connected the following way on the shield:

Bluetooth to serial HC-06 wireless module

Guangzhou HC Information Technology Co., Ltd. Product Data Sheet

Lab 6 Introduction to Serial and Wireless Communication

Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]

Using Xbee in Serial Communication

Building a Basic Communication Network using XBee DigiMesh. Keywords: XBee, Networking, Zigbee, Digimesh, Mesh, Python, Smart Home

Bluetooth Installation

Wireless Communication With Arduino

2.4G Bluetooth Datalink & ipad Ground Station User Guide V1.02

MANUAL FOR RX700 LR and NR

Smarthome SELECT Bluetooth Wireless Stereo Audio Receiver and Amplifier INTRODUCTION

Cisco Aironet Wireless Bridges FAQ

In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM

Quick Start Guide. MRB-KW01 Development Platform Radio Utility Application Demo MODULAR REFERENCE BOARD

Condemn the copycat company copied behavior on HM-10!!!!!! If you buy a fake, please apply for a refund guarantee your legitimate rights

RN-52 Bluetooth Hookup Guide

Yun Shield User Manual VERSION: 1.0. Yun Shield User Manual 1 / 22.

Ethernet Radio Configuration Guide

Secure Ethernet Gateway SEG-1 and SEG-M for IEI Access Systems Installation Manual

DSX Master Communications

Arduino Lesson 5. The Serial Monitor

Programming Flash Microcontrollers through the Controller Area Network (CAN) Interface

How to setup the UCW232C Serial WiFi adapter

BIT COMMANDER. Serial RS232 / RS485 to Ethernet Converter

DSO138 oscilloscope program upgrade method

RN-XV-RD2 Evaluation Board

How to setup a serial Bluetooth adapter Master Guide

RS-232 Communications Using BobCAD-CAM. RS-232 Introduction

PM1122 INT DIGITAL INTERFACE REMOTE

RN-131-PICTAIL & RN-171-PICTAIL Evaluation Boards

Bluetooth for device discovery. Networking Guide

ESP8266 WiFi Module Quick Start Guide

Guangzhou HC Information Technology Co., Ltd. Product Data Sheet

Guangzhou HC Information Technology Co., Ltd. Product Data Sheet

Serial to Bluetooth Adapter

IR Communication a learn.sparkfun.com tutorial

Bluetooth Serial Adapter

WPR400 Wireless Portable Reader

Testing Data Radio Modem with Serial Port Tool V1.20

EZ-View Network Communications Guide

PHYS 2P32 Project: MIDI for Arduino/ 8 Note Keyboard

2.4G Bluetooth Datalink & ipad Ground Station User Guide V1.12

Waspmote. Quickstart Guide

CAN-Bus Shield Hookup Guide

Guide to programming a Rako wireless module system using Rasoft

MeshBee Open Source ZigBee RF Module CookBook

Bidirectional wireless communication using EmbedRF

[USING THE NM150 WITH ADULTICIDING] July 13, 2015

Yun Shield Quick Start Guide VERSION: 1.0 Version Description Date 1.0 Release 2014-Jul-08 Yun Shield Quick Start Guide 1 / 14

Using a Laptop Computer with a USB or Serial Port Adapter to Communicate With the Eagle System

WIRELESS INSTRUMENTATION TECHNOLOGY

NETGEAR Trek N300 Travel Router and Range Extender

Manual Instruction for. AU06-DL13W/RGB/30K MiLight Wifi LED Controller

Step-by-Step Tutorial For Using LinkSprite UART- WIFI Module Model LS_UART_WIFI

PICAXE RF CONNECT KIT (AXE213)

telstra.com/ppmbb visit a telstra store or partner GETTING TO KNOW YOUR

The LimitlessLED Wifi Bridge 4.0 is compatible with RGBW(new), RGB(old), and Dual White(current) LimitlessLED lightbulbs.

PN532 NFC RFID Module User Guide

WUA Mbps Wireless USB Network Adapter

DragonLink User Guide

Arduino ADK Back. For information on using the board with the Android OS, see Google's ADK documentation.

TCP/IP MODULE CA-ETHR-A INSTALLATION MANUAL

Jabra FREEWAY. User manual.

Programming and Using the Courier V.Everything Modem for Remote Operation of DDF6000

Application of IEEE to Distribute Cell Phone Calls through a Home Phone Network

To perform Ethernet setup and communication verification, first perform RS232 setup and communication verification:

Advanced Data Capture and Control Systems

XBee USB Adapter Board (#32400)

Arduino DUE + DAC MCP4922 (SPI)

Using the VEX Cortex with ROBOTC

Bluetooth UART/RS232 Module

Accessing AT&T U-verse Web Remote

GETTING TO KNOW YOUR TELSTRA PRE-PAID 3G WI-FI

Preparing the Computers for TCP/IP Networking

Using HyperTerminal with Agilent General Purpose Instruments

DOORKING SYSTEMS 1830 SERIES NETWORK WORKSHOP LAN APPLICATIONS ACCESS CONTROL SOLUTIONS LOCAL AREA NETWORK (LAN) CONNECTION REV 04.

User Manual. AS-Interface Programmer

GSM Interfacing Board

RN-41/RN-41-N Class 1 Bluetooth Module

Introduction. Getting familiar with chipkit Pi

1. Make sure that no client accounts are open. 2. Click on Setup, then click Modem. The Modem Setup window will appear.

RDF1. RF Receiver Decoder. Features. Applications. Description. Ordering Information. Part Number Description Packages available

GSM Alarm System User Manual

USB to RS-422/485 Serial Adapter

DECT Module UM-9802 Datasheet

How to setup the UCW232C Serial WiFi adapter

User Guide. E-Series Routers

RFD radio modem software manual For RFD900A, RFD900u, RFD900+ radio modems

iloq P10S.10/20 Programming device User's Guide

Work with Arduino Hardware

User Manual Revision English Converter / Adapter Ethernet to RS232 / RS485 (Order Code: HD HD M HD HD M)

Disclaimers. Important Notice

Surveillance System Using Wireless Sensor Networks

Single channel data transceiver module WIZ2-434

TO RJ45&WIFI CONVERT SERVER

TOSR0X-D. USB/Wireless Timer Relay Module. User Manual. Tinysine 2013 Version 1.0

Arduino Lesson 1. Blink

Transcription:

AN INTRODUCTION TO BLUETOOTH MODULES (HC-05 & HC-06) An Introduction to Bluetooth Modules 1 P a g e

Contents Introduction to Bluetooth Technology... 2 Advantages and Disadvantages... 3 Advantages... 3 Disadvantages... 3 Introduction to HC-05 and HC-06 Modules... 3 HC 05... 3 HC 06... 4 Hooking up with Arduino... 5 HC-05 with Arduino... 5 HC-06 with Arduino... 7 Configuring HC-05 with AT commands... 7 HOW TO PAIR TWO BLUETOOTH MODULES (HC-05)... 9 WIRELESS PROGRAMMING USING HC-05 BLUETOOTH MODULE... 12 Step 1: Install the latest beta version of Arduino... 13 Step 2: Bread-board the Bluetooth module setup circuit... 13 Step 3: Upload the setup sketch... 14 Step 5: Setup the Bluetooth module in Windows... 18 Step 6: Set-up the Bluetooth module in Windows (cont'd)... 19 Step 7: Solder a jumper onto the Bluetooth module... 21 Step 9: Program the Arduino with Bluetooth... 23 References... 23 Introduction to Bluetooth Technology Bluetooth is a wireless communication technology used for exchange of data over short distances. It is found in many devices ranging from mobile phones and computers. Bluetooth technology is a combination of both hardware and software. It is intended to create a personal area networks (PAN) over a short range. It operates in the unlicensed industrial, scientific and medical (ISM) band at 2.4 to 2.485 GHz. It uses a radio technology called frequency hopping spread spectrum. Bluetooth technology s adaptive frequency hopping (AFH) was designed to reduce interference between wireless technologies sharing the 2.4 GHz spectrum. This adaptive hopping among 79 frequencies at 1 MHz intervals gives a high degree interference immunity. Thus the Bluetooth divides the data that need to be transmitted into packets and each packet are transmitted on one of 79 designated Bluetooth channels. The bandwidth of each channel is 1 MHz.It is An Introduction to Bluetooth Modules 2 P a g e

a packet-based protocol with a master-slave structure. Each master can communicate with up to 7 slaves in a piconet. The range of Bluetooth depends upon the class of radio using. Class 3 radios have range up to 1 meter or 3 feet. Class 2 radios have range of 10 meters or 33 feet. Class 1 radios have range of 100 meters or 300 feet. The most commonly used radio is Class 2. Advantages and Disadvantages Advantages The biggest advantage of using this technology is that there are no cables or wires required for the transfer of data over short ranges. Bluetooth technology consumes less power when compared with other wireless communication technologies. For example Bluetooth technology using Class 2 radio uses power of 2.5 mw. As it is using frequency hopping spread spectrum radio technology there is less prone to interference of data if the other device also operates in the same frequency range. Bluetooth doesn t require clear line of sight between the synced devices. Disadvantages Since it uses the greater range of Radio Frequency (RF), it is much more open to interception and attack. It can be used for short range communications only. Although there are fewer disadvantages, Bluetooth still remains best for short wireless technology. Introduction to HC-05 and HC-06 Modules HC 05 HC-05 is a class 2 Bluetooth module with Serial Port Profile (SPP). It can be configure either as master or salve. It is a replacement for wired serial connection. An Introduction to Bluetooth Modules 3 P a g e

The datasheet of the Bluetooth module is below http://www.robotshop.com/media/files/pdf/rb-ite-12-bluetooth_hc05.pdf HC-05 Specification: Bluetooth Protocol : Bluetooth Specification v2.0 + EDR Frequency : 2.4 GHz ISM band Profiles : Bluetooth Serial Port Working Temperature : -20 to + 75 centigrade Power of emitting : 3 dbm The pins on the module are: Vcc Power supply for the module. GND Ground of the module. TX Transmitter of Bluetooth module. RX Receiver of the module. Key Used for the module to enter into AT command mode. HC 06 HC-06 is a drop-in replacement for wired serial connection. This can be used as serial port replacement to establish connection between PC and MCU (Microcontroller). This is a Slave Mode only Bluetooth device. This module can be configured for baud rates 1200 to 115200 bps. The datasheet of HC-06 module is in the below link: http://www.electronicoscaldas.com/datasheet/hc-06_wavesen.pdf HC-06 Module Features: An Introduction to Bluetooth Modules 4 P a g e

Encrypted connection Frequency : 2.4 2.524 GHz Bluetooth core v2.0 Serial Port Profile (SPP) support Hooking up with Arduino HC-05 with Arduino The connections are: HC-05 Arduino Vcc -----------> 5V GND -----------> GND TX -----------> RX RX -----------> TX HC-05 is connected to Arduino as shown in above figure. The Bluetooth module will be blinking with a delay of 1 second when it is powered. If HC-05 is to be paired from PC, search for the available Bluetooth devices from PC and there should be a device named HC-05. Pair with it and the default passcode is 1234(You can change it later from AT commands). If HC-05 is paired it blinks it with a delay of 2 seconds. If a Bluetooth module is connected to laptop it opens a COM port, hence in PC using Device Manager search for which COM port the Bluetooth module is connected. An Introduction to Bluetooth Modules 5 P a g e

Let s control the LED on Arduino using a basic code to send command over Bluetooth. The code is below. char ch; void setup() { Serial.begin(9600); pinmode(13,output); } void loop() { if(serial.available()) { ch=serial.read(); if(ch=='h') { digitalwrite(13,high); } if(ch=='l') { digitalwrite(13,low); } } } In the above code if h (without quotes) is entered in the Serial port the LED (which is interconnected to 13 th pin of Arduino) will glow. If l (without quotes) is entered the LED will turn off. Now upload the code to Arduino and pair with HC-05 and open the COM port to which HC-05 is connected. Now enter the commands h or l to control the Arduino. Thus, successfully you controlled the Arduino using HC-05. You can make the changes to code as per your requirement. Note: Here the HC-05 TX and RX are connected to RX (0) and TX (0) of Arduino Uno. If you use other Arduino there are more than one serial ports. So while writing the code write correct serial port number to which RX and TX of HC-05 are connected. For example if you use Arduino MEGA there are 4 serial ports. Consider if TX and RX of HC-05 are connected to RX (1) and TX (1) of MEGA then replace Serial with Serial1 in code and upload it. An Introduction to Bluetooth Modules 6 P a g e

HC-06 with Arduino The connections are: HC-06 Vcc -----------> 5V Arduino GND -----------> GND TX -----------> RX RX -----------> TX HC-06 is same as HC-05 but the only difference is HC-06 is slave mode only while HC-05 can be configured as either master or slave. Hence the program used for HC-05 can be used for this module also and can control the Arduino. Configuring HC-05 with AT commands HC-05 can be configured i.e. its name and password can be changed and many more using AT commands. It can also be configured as either master or slave. To set the HC-05 into AT command mode the KEY pin of the module is made high i.e. it is connected to either 5V or 3.3V pin of Arduino and TX of Arduino is connected to TX of HC-05 and RX of HC-05 to RX of Arduino. The connections with Arduino are shown in the below figure: An Introduction to Bluetooth Modules 7 P a g e

Power up the Arduino after connecting HC-05 to it. It is known that HC-05 entered into AT command mode by observing the blinking of LED on Bluetooth module. It blinks with a delay of 2 seconds. To enter the AT commands open up the COM port of the Arduino to which the Bluetooth module is connected and set the baud rate to 38400. After opening COM port if you enter command AT (without quotes) it should return OK thus it can be said that HC-05 entered into AT command mode. Let s see some of AT commands to change the name and password of HC-05 module. To change the name enter command AT + NAME = <Param> (without quotes). Where <Param> is Bluetooth device name. To change the password enter command AT + PSWD =<Param> (without quotes). Where <Param> is Bluetooth device passkey (default is 1234). To check the role (master or slave) of the Bluetooth device enter command AT+ROLE? (without quotes). If it returns 0 it is in Slave mode, if it returns 1 it is in Master mode. You can also set the role of HC-05 using command AT + ROLE = <Param> Where Param=0 for Slave mode and 1 for Master mode. An Introduction to Bluetooth Modules 8 P a g e

The above are basic AT commands you can use. It will return OK after each command is executed. The below is the list of AT commands you can use for configuring your Bluetooth module. http://www.linotux.ch/arduino/hc- 0305_serial_module_AT_commamd_set_201104_revised.pdf These AT commands are used to set the baud rate, name, passkey, remote Bluetooth device address etc. HOW TO PAIR TWO BLUETOOTH MODULES (HC-05) It is quite simple to pair a Bluetooth module from your Android phone. But bit tricky to pair it with another HC-05 module. In this post I ll describe the method of pairing 2 Bluetooth modules. One of the module is assigned ROLE as MASTER & the other left as SLAVE. By default all HC-05 modules are SLAVES. Using AT commands the module can be configured as we like. To configure the SLAVE we make use of an Arduino UNO board. Not much of configuration needed for slave. We can leave it to defaults. But to know the ADDRESS of the slave you ve to follow this procedure. Before connecting the HC05 module, upload an empty sketch to Arduino. This bypasses the Boot loader of UNO & the Arduino is used as USB- UART converter. An Introduction to Bluetooth Modules 9 P a g e

After uploading this empty sketch, remove USB power from Arduino & do the following connections with HC05 Slave: - ARDUINO HC05 Rx (pin0) > Rx TX (pin1) > TX +5v > VCC GND > GND +3.3V > KEY Remember it is one to one connection here & not cross connection Now provide the USB cable power to Arduino. The HC-05 module enters the Command mode with Baud Rate 38400. Open the Serial Monitor of Arduino. Ensure to select BOTH NL & CR & Baud Rate as 38400 at the bottom of the serial monitor. This is very important as the Bluetooth module HC- 05 expects both Carriage Return and Line Feed after every AT command. An Introduction to Bluetooth Modules 10 P a g e

If you type in AT & click on SEND button you should get an OK confirmation from the HC-05 module. If you get ERROR (0) try again to enter the Command mode. If there is no response then check whether correct COM port has been assigned in Arduino IDE & confirm Baud Rate is 38400, Both NL & CR selected. Type in AT+NAME? To get the name of the module. You can change the name as you like with AT+NAME=HC05_SLAVE The password by default is 1234.Confirm that with AT+PSWD? The ROLE of the module can be known by typing AT+ROLE? You can change it by AT+ROLE=0 (0 for SLAVE & 1 for Master). Leave it as 0 as we want this module to be SLAVE. You should know the Address of this module to make it pair with another. Type in AT+ADDR? & note the Address. Here it is 14:2:110007. While using this address in AT commands you should replace the colon with a comma, like 14, 2,110007 An Introduction to Bluetooth Modules 11 P a g e

Now remove the KEY connection from the HC05 module & disconnect the power. Again provide the power to see STATUS LED on the module blinking fast indicating that it is looking for a PAIR. Now we have the slave Bluetooth module ready. Now we have to setup the master Bluetooth module. NOTE: SAME CONNECTION IS USED FOR CONFIGURING THE MASTER MODULE AS THAT OF SLAVE MODULE. If you type in AT & click on SEND button you should get an OK confirmation from the HC-05 module. If you get ERROR (0) try again to enter the Command mode. If there is no response then check whether correct COM port has been assigned in Arduino IDE & confirm Baud Rate is 38400, Both NL & CR selected. Type in AT+NAME? To get the name of the module. You can change the name as you like with AT+NAME=HC05_MASTER The password by default is 1234.Confirm that with AT+PSWD? The ROLE of the module can be known by typing AT+ROLE? Change it master mode by typing following AT command: AT+ROLE=1 (0 for SLAVE & 1 for Master) Now, type the following AT Command to pair with the slave module. AT+LINK=14, 2,110007 NOTE: BEFORE TYPING THIS AT COMMAND, MAKE SURE THAT OTHER MODULE MUST BE POWERED SO THAT THEY CAN BE PAIRED. If it returns OK it means the module is set to pair with the slave module when both module are switched on at same time. Hence, the two modules are paired. WIRELESS PROGRAMMING USING HC-05 BLUETOOTH MODULE We generally program the Arduino board USB cable. But using HC-05 Bluetooth module we can program the Arduino board without USB cable that is by An Introduction to Bluetooth Modules 12 P a g e

wirelessly. We need to modify the hardware little bit for the wireless programming and steps required for wireless module are shown below. Step 1: Install the latest beta version of Arduino The current beta version of the Arduino IDE has fixed some of the issues that made Bluetooth programming difficult in the past. The most current version available today is Arduino 1.5.6-r2. You can download the installer from: http://arduino.cc/en/main/software Step 2: Bread-board the Bluetooth module setup circuit The Bluetooth module used in this project is the HC-05. It is inexpensive and one of the most common modules you'll see in a lot of other projects. The HC-05 is sold bare or mounted to a breakout board. You want one on a 6-pin breakout board. Using a breadboard, temporarily wire the HC-05 Bluetooth module per the schematic. With 3.3v on the Key pin, the module will enter 38400 baud command mode and will accept AT commands. The Key pin must be connected to An Introduction to Bluetooth Modules 13 P a g e

3.3v when the module is powered on. If it is connected afterwards, the module will enter command mode at the default baud rate (as set by the 'AT+UART=' command or 9600 baud from the factory). Step 3: Upload the setup sketch An Introduction to Bluetooth Modules 14 P a g e

The above sketch is attached below, upload it to your Arduino. /* Serial Loop */ #include <SoftwareSerial.h> #define rxpin 8 #define txpin 9 SoftwareSerial myserial(rxpin, txpin); // RX, TX char mychar ; void setup() { Serial.begin(9600); Serial.println("AT"); } myserial.begin(38400); myserial.println("at"); void loop() { while (myserial.available()) { mychar = myserial.read(); Serial.print(myChar); } } while (Serial.available()) { mychar = Serial.read(); Serial.print(myChar); //echo myserial.print(mychar); } An Introduction to Bluetooth Modules 15 P a g e

Step 4: Run the setup sketch and enter serial commands Open the serial console and make sure the baud rate is set to 9600 and line endings is set to be "Both NL & CR" Enter the following AT commands into the serial console. AT AT+ORGL AT+ROLE=0 AT+POLAR=1,0 AT+UART=115200,0,0 AT+INIT In order, these commands tell the module to reset to factory settings, switch to slave role (transparent serial bridge), set pin 32 low on An Introduction to Bluetooth Modules 16 P a g e

Bluetooth connection, change baud rate to match the Arduino Uno programming rate, and to initialize. Disconnect 3.3v from the Key pin and cycle the power to the module. It will now be running at 115200 baud and be in pairing mode. An Introduction to Bluetooth Modules 17 P a g e

Step 5: Setup the Bluetooth module in Windows An Introduction to Bluetooth Modules 18 P a g e

From the Control Panel select add a Device. Add the Bluetooth module. Select enter pairing code option. Step 6: Set-up the Bluetooth module in Windows (cont'd) An Introduction to Bluetooth Modules 19 P a g e

Enter "1234" for the pairing code. At the Add a device success window, click Close. Device ready to use. The OS will create two serial COM ports associated with the device. Always use the one with the lower number. An Introduction to Bluetooth Modules 20 P a g e

Step 7: Solder a jumper onto the Bluetooth module Disassemble the bread boarded circuit. Solder a jumper wire directly to the HC-05's Pin 32. Don't forget to use flux. You may want to use hot glue or tape to protect the joint. Step 8: Build the programmer circuit. An Introduction to Bluetooth Modules 21 P a g e

Build the programmer circuit onto the prototyping shield. Solder on a female header for the Bluetooth module if you want to be able to easily remove it later. An Introduction to Bluetooth Modules 22 P a g e

Step 9: Program the Arduino with Bluetooth Power on the Arduino from a battery or AC adapter. In the Arduino IDE, choose the serial port of the Bluetooth module (the lower valued one of the two) and then upload a sketch like normal. Hence the Arduino board is programmed wirelessly using HC-05 Bluetooth module. References https://alselectro.wordpress.com/2014/10/18/bluetooth-module-hc- 05how-to-pair-2-modulesat-command-walkthrough/ https://alselectro.wordpress.com/2014/10/21/bluetooth-hc05-how-to-pairtwo-modules/ http://www.bluetooth.com/pages/how-it-works.aspx http://makezine.com/projects/diy-arduino-bluetooth-programming-shield/ An Introduction to Bluetooth Modules 23 P a g e