HC-02 Bluetooth serial communication module is based on the Bluetooth V2.0 Bluetooth protocol data transmission module, high stability, ultra low power consumption, industrial grade Bluetooth data transmission module.
Users do not need to care about complex wireless communication configuration and transmission algorithms. They only need to connect to devices through TTL serial port. Powered the HC-02 slave module, and can be connected to the mobile phone for data transmission. In addition, it can be used with HC-05 or HC-06 hosts (matching code, default is 1234) to connect, can replace a traditional serial line, save wiring work. It's very flexible.
If you need to use iphone or ipad to control your arduino project, hc-02 4.0 ble slave module with 6pin baseboard may be a good choice.Fully compatible with ios7.0 or later.Also compatible with Android 4.3 or later.
In this lesson, we will show what is HC-02 bluetooth module and how to setup communications between an Arduino and a Bluetooth device running serial terminal software - in this case an Android/iOS smartphone. Please note that the Bluetooth module used in this tutorial is not compatible with iOS devices.
- If the version of the Android os is less than 4.3. it is not compatible.
- This module supports bluetooth 4.0 ble mode and bluetooth 2.0 mode.
- If you are not so familiar with the Bluetooth, you can get more info about blutooth from here.
||built-in PCB antenna
|The transmitting power
||-40 C ~+85 C
||-25 C ~75 C
- Core module uses HC-02, leads from the module interface includes VCC, GND, TXD, RXD, LED status output pin.
- Led indicate Bluetooth connection status, flashing Bluetooth connectivity, lit the Bluetooth connection and open a port Backplane
- 3.3V LDO input voltage 3.6 6V, the input voltage to prohibit more than 7V
- The interface level 3.3V, can be directly connected the various SCM (51, AVR, PIC, ARM, MSP430, etc.), the 5V MCU also can be connected directly.
- Open to the effective distance of 10 meters, over 10 meters is also possible, but not of this the quality of the connection of the distance do to ensure.
- After the pair when full-duplex serial port to use, do not need to know anything about the Bluetooth protocol, but only supports 8 data bits, 1 stop bit, no parity communication format, which is the most commonly used communication format does not support other formats .
- Compact (3.57cm * 1.52cm), the factory chip production to ensure the placement quality. And sets of transparent heat shrink tubing, dust and beautiful, and anti-static.
||Enable / Key
||This pin is used to toggle between Data Mode (set low) and AT command mode (set high). By default it is in Data mode
||Powers the module. Connect to +5V/+3.3V Supply voltage
||Ground pin of module, connect to system ground.
||TX – Transmitter
||Transmits Serial Data. Everything received via Bluetooth will be given out by this pin as serial data.
||RX – Receiver
||Receive Serial Data. Every serial data given to this pin will be broadcasted via Bluetooth
||The state pin is connected to on board LED, it can be used as a feedback to check if Bluetooth is working properly.
||Indicates the status of Module
- Blink once in 2 sec: Module has entered Command Mode
- Repeated Blinking: Waiting for connection in Data Mode
- Blink twice in 1 sec: Connection successful in Data Mode
More info about the HC-02 BLE module please check this link.
- Osoyoo UNO Board (Fully compatible with Arduino UNO rev.3) x 1
- HC-02 Bluetooth Module x 1
- Android smartphone x 1
- iPhone(ios7.0 or later) x 1
- USB Cable x 1
- PC x 1
- Arduino IDE (version 1.6.4+)
- Arduino library: SoftwareSerial.h
- Amarino app for Android
- Bluetooth Terminal app for iOS
In this example, we will show how to use an smart phone to control the Arduino on-board LED via bluetooth protocol.
Overhere we use the Software serial port of the Arduino, connect them as below fritzing:
After above operations are completed, connect the Arduino board to your computer using the USB cable. The green power LED (labelled PWR
) should go on.Open the Arduino IDE and choose corresponding board type and port type for you project. Then load up the following sketch
onto your Arduino.
#include <SoftwareSerial.h>// import the serial library
SoftwareSerial mySerial(10, 11); // RX, TX
int ledpin=13; // led on D13 will show blink on / off
int BluetoothData; // the data given from Computer
Serial.println("Type AT commands!");
// put your setup code here, to run once:
Serial.println("Bluetooth On please press 1 or 0 blink LED ..");
// put your main code here, to run repeatedly:
// if number 1 pressed ....
Serial.println("LED On D13 ON ! ");
// if number 0 pressed ....
Serial.println("LED On D13 Off ! ");
delay(100);// prepare for next data ...
For Android Smart Phone User
Install and config the Amrion App
Open the App and it will search for this Bluetooth module.
When the connection will be prompted for pairing, input 1234 to the column, if not, you can try 0000,
As above photo, the green box is lit to indicate the connection is successful. At the same time, the LED light of Bluetooth module has become bright all the time.
Then click the Monitoring button in the lower right, and enter the following interface:
Just input your command and press the Send button here.
For iPhone User
Download the Bluetooth Terminal app from the APP Store.
After the above operation is completed, open the Bluetooth Terminal, and you will see the bluetooth list as below:
Choose "HC-02", then click the connect button.
In this step, click "Select Characteristic", you will see a scroll bar below the button, select entries with the beginning of "49535343-8841-43F4-A8D4" for your HC-02 BLE module.
Choose "ASCII", and you can enter your command here, just press the "Send" button to send your command to the Arduino via bluetooth.
A few seconds after the upload finishes, open the Amarino app and connect your andorid samart phone with the HC-02 module, simply type "1" or "0" to above corresponding APP column, you will see the on-board LED turn on/off,
At the same time, the output of the Serial Monitor is as below:
Note: you must choose the correct Baudrate for your serial monitor, be careful!!!