HC-05 Bluetooth Transceiver Module with TTL Serial Output


Industrial serial port bluetooth, Drop-in replacement for wired serial connections, transparent usage. You can use it simply for a serial port replacement to establish connection between MCU and GPS, PC to your embedded project and etc. Computer and peripheral devices.



Serial port bluetooth, Drop-in replacement for wired serial connections, transparent usage. You can use it simply for a serial port replacement to establish connection between MCU and GPS, PC to your embedded project and etc.

  • Bluetooth protocal: Bluetooth Specification v2.0+EDR
  • Frequency: 2.4GHz ISM band
  • Modulation: GFSK(Gaussian Frequency Shift Keying)
  • Emission power: ≤4dBm, Class 2
  • Sensitivity: ≤-84dBm at 0.1% BER
  • Speed: Asynchronous: 2.1Mbps(Max) / 160 kbps, Synchronous: 1Mbps/1Mbps
  • Security: Authentication and encryption
  • Profiles: Bluetooth serial port
  • Power supply: +3.3VDC 50mA
  • Working temperature: -20 ~ +75 Centigrade
  • Dimension: 26.9mm x 13mm x 2.2 mm


After pairing only need as fixed baud rate of the serial port as can be, so long as it is "fixed baud rate, 8 data bits, no parity" serial communication format equipment can be a direct replacement for the original wired serial port without the need to modify the program. Such as
data acquisition, smart car, serial printer, outdoor lattice strip screen control.Paired with computer use: for computers and devices via Bluetooth serial communication, use serial paired with the phone use: suitable for the mobile phone with the device through Bluetooth serial communication, use serialpaired with the Bluetooth host: for the two devices directly through the Bluetooth serial communication between the microcontroller and the microcontroller wired serial interface with microcontroller between use with serial.

Arduino AND Bluetooth HC-05 Connecting Easily

After reading this article you will be able to:

  1. Connect arduino Board with PC By Bluetooth , to send and receive data .
    2)Connect arduino Board with Any android device .

so you can send your information , Like Sensors reading , from arduino to PC Or android device , and you can build your Home automation system by bluetooth , and controlling your robot wirelessly

Step 1: Material and Connection




you need to do this experiment :

  1. Arduino Board " here we used Arduino Uno ".
  2. Bluetooth module HC-05.
    3)Solderless jumper.
    4)Bread Board .
    5)Battery 9V "Optional".

The connction between Arduino and bluetooth is like the schematic above

Step 2: Connect Arduino With PC

We now want to send or receive Data between arduino and computer , first we need to make a Communication link to Definition arduino Board to the computer.
We will need a software called Tera Term to show the data received or what we want to send through it .
You can download Tera Term or any terminal emulator software , you can download Tera term from this link :

To make a link between your Arduino and bluetooth , do the following :

  1. Go to the bluetooth icon , right click and select Add a Device
  2. Search for new device , Our bluetooth module will appear as HC-05 , and add it .
  3. The pairing code will be 1234 .
    4)after make a pairing , we can now program the arduino and upload a sketch to send or receive data from Computer.

Step 3: Arduino Code

We will use software serial library to make pin D10 & D11 As Tx & Rx instead of using the default Rx and tx " D0 &D1 On most arduino Board ".

this program below allow us to control LED connected to D13 To blink on/off , by press # 1 from PC Keyboard the LED blink on , and if we press 0 LED blink off !

To send the Control commands from Computer to arduino , Go to the tera term , Run it , and choose Serial , and select the bluetooth Serial from the list as Shown on the picture .

The code below :

// This program shown how to control arduino from PC Via Bluetooth
// Connect ...
// arduino>>bluetooth
// D11   >>>  Rx
// D10   >>>  Tx
//Written By Mohannad Rawashdeh
//for http://www.genotronex.com/

// you will need arduino 1.0.1 or higher to run this sketch

#include <SoftwareSerial.h>// import the serial library

SoftwareSerial Genotronex(10, 11); // RX, TX
int ledpin=13; // led on D13 will show blink on / off
int BluetoothData; // the data given from Computer

void setup() {
  // put your setup code here, to run once:
  Genotronex.println("Bluetooth On please press 1 or 0 blink LED ..");

void loop() {
  // put your main code here, to run repeatedly:
   if (Genotronex.available()){
   if(BluetoothData=='1'){   // if number 1 pressed ....
   Genotronex.println("LED  On D13 ON ! ");
  if (BluetoothData=='0'){// if number 0 pressed ....
   Genotronex.println("LED  On D13 Off ! ");
delay(100);// prepare for next data ...

After uploading This sketch go to tera term and press 0 or 1 and see the results.
This Video show the results of this code.

Step 4: Connect Arduino to Android Device
after we finished from connecting arduino with PC By bluetooth , let's move to how we can connect arduino To android device .

at first you need a terminal emulator on your andriod device to send or receive data to arduino .

You can download this app from Google play.


after that , you can use the same arduino Sketch and control LED Blinking on or Off from android device .

just type and t send #1 to make LED Blink on , or 0 to blink off.

this video below show how to control arduino I/O from android tablet.

Step 5: Receiving Data From Arduino
Now in this program we will use arduino to Calculate the time since the start of the program in second , and send it Via bluetooth to any pairing device.

the code below:

// This program shown how to control arduino from PC Via Bluetooth
// Connect ...
// arduino>>bluetooth
// D11   >>>  Rx
// D10   >>>  Tx
//Written By Mohannad Rawashdeh
//for http://www.genotronex.com/

// you will need arduino 1.0.1 or higher to run this sketch

#include <SoftwareSerial.h>// import the serial library

SoftwareSerial Genotronex(10, 11); // RX, TX
int ledpin=13; // led on D13 will show blink on / off
long previousMillis = 0;        // will store last time LED was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 1000;           // interval at which to blink (milliseconds)
int ledState = LOW;             // ledState used to set the LED
long Counter=0; // counter will increase every 1 second
void setup() {
  // put your setup code here, to run once:
  Genotronex.println("Bluetooth On please wait....");

void loop() {
  // put your main code here, to run repeatedly:
  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;  
    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledpin, ledState);

A cheap Bluetooth serial port for your Raspberry Pi


In this article we describe how to enable the Raspberry Pi's serial port to talk to other devices over Bluetooth using this module.

Required hardware
The nice aspect of this project is that it requires very little hardware, most of the action happens in the software side. But of course we do need some hardware, which is listed below:

  • A Raspberry Pi.
  • A Bluetooth slave module
  • Four female-to-female breadboard wires
  • A computer or device with a Bluetooth terminal software
    To establish a communication with the Raspberry Pi over Bluetooth you need another device that can speak Bluetooth. If your computer has a Bluetooth adapter then you just need to find a terminal software that you can use to send and receive data, like HyperTerminal on Windows, or screen on OS X and Linux. A computer is not the only choice, though. For example, we will use the Android cell phone with the free BlueTerm app installed.

The wiring is very simple and is better explained with a diagram:
If you prefer to see it in table format, here are the four connections that you need to make:

RPi GPIO pin BT module pin
5V (Pin #2) VCC
GND (Pin #6) GND
TXD (Pin #8) RXD
RXD (Pin #10) TXD

Note that the TXD and RXD connections between the RPi and the Bluetooth module are crossed, this is what makes one end receive what the other end sends.

Raspberry Pi configuration

We are going to assume you are running a recent release of Raspbian on your Raspberry Pi. If you are running another OS then you will need to find out how the changes below are done in your system.

By default the Raspberry Pi is configured to write boot time messages to the serial port, and also to start a login console on it. Unfortunately, the default baud rate that the RPi uses for its serial port is 115200 bps, while the Bluetooth module comes preconfigured from factory to 9600 bps.

It is easier to configure the RPi to use 9600 bps so we will try that first. There are two config files that need to be updated.

File /boot/cmdline.txt contains the kernel options that are used to boot the system. In my Raspbian based system this file contains the following options:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

The interesting options are console and kgdboc, because these configure the serial port device /dev/ttyAMA0 to 115200 bps. You need to change these two configurations to 9600 bps. After you make these changes the file should read:

dwc_otg.lpm_enable=0 console=ttyAMA0,9600 kgdboc=ttyAMA0,9600 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

The second configuration file is /etc/inittab. Inside this file you have to locate the following line:

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

This tells the system to start a terminal on the serial port, and again it uses 115200 bps to configure the port. You have to change this line to use 9600 bps:

T0:23:respawn:/sbin/getty -L ttyAMA0 9600 vt100

Remeber that these are configuration files so they are not writable to the default pi user, to edit these files you have to use sudo. As far as text editors, Raspbian provides two, vi and pico. If you don't know either then you will probably be more confortable using pico. For example, to edit cmdline.txt with pico you would run the following command:

$ sudo pico /boot/cmdline.txt

The system will ask for your password and after that you will be able to make changes to this file. We recommend that you save original copies of these config files in case you make a mistake.

With those changes made the RPi is configured to talk to the Bluetooth module. If you now power up your Raspberry Pi you will notice that the LED in the Bluetooth module blinks rapidly. This is the sign that the Bluetooth module is ready and waiting to be paired with another device.

Connecting from a Bluetooth terminal
Now leave the RPi running with the Bluetooth module in its blinking state and go to the Bluetooth enabled computer or smartphone that you will connect to it. Your device should now find the Bluetooth module with the name linvor when you set it to discover devices.

If you are using an Android device with BlueTerm then start the app and from the app menu select "Connect device". Android does the baud selection automatically so you don't have to configure it. From a terminal software running in a computer it is likely that you will need to configure the speed, number of data bits per character, parity, and number of stop bits per character. The values you need to use are:

  • Speed: 9600 bps
  • Data bits: 8 bits
  • Parity: None
  • Stop bits: 1 bit

The Bluetooth module comes preconfigured with a PIN number. To complete the connection your computer or smartphone will ask you to enter this PIN. The factory default PIN is 1234.

The LED in the Bluetooth module will now stop blinking and remain lit, indicating that it has made a connection.

And here comes the fun part. You need to reboot the Raspberry Pi so that the new serial port settings take effect. To reboot the RPi run the following command in a local or network shell:

$ sudo reboot

Now watch the Bluetooth terminal on your PC or smartphone while the Pi reboots. Boot messages should be appearing on your terminal, and as soon as the RPi is up you should get a login prompt there as well.

You can now login from your Bluetooth terminal and use the command line prompt as you normally would over a local or network shell.

Direct serial port access
While you can't deny there is a coolness factor in being able to run a Raspberry Pi from a smartphone, let's be honest, that isn't extremely useful. But having a wireless serial connection into the RPi can be useful for regular applications, for example for debugging or for remote control.

To be able to use the serial port from a user application running in the Raspberry Pi we first need to tell the system to not use it as a console. To do this we need to go back to the two configuration files we touched before. I once again recommend that you back up your config files before changing them, in case things don't work out well and you need to revert the changes.

In file /boot/cmdline.txt we are going to remove the two serial references by taking away the first console and kgdboc sections:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

And in file /etc/inittab we will comment out the serial console task:

#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

After making these changes reboot the system so that they take effect. With these changes the RPi will not use the serial port at all, so the port will be free to any application that wants to use it as /dev/ttyAMA0.

If you want to play with sending and receiving data through the serial port then you can install minicom into your RPi using the following command:

$ sudo apt-get install minicom

And then you can open a terminal on the serial port with this command:

$ minicom -b 9600 -o -D /dev/ttyAMA0

Anything you type inside the minicom terminal will be sent to the serial port, and anything the other side sends will be displayed.

Configuring the Bluetooth module

The Bluetooth module comes preconfigured from the factory with a set of defaults, which are:

  • Baud rate: 9600
  • Bluetooth ID: linvor
  • PIN: 1234

But these values can be changed by sending special commands through the communication channel. Now that the Raspberry Pi is connected to the module we can try this.

These special commands that configure the Bluetooth module can be sent from a connected remote device, or they can be sent from the local system, in this case the Raspberry Pi. Since the Raspberry Pi is the star of the article we are going to also use it to do the configuration.

Command Description
AT Test the communication with the Bluetooth module.
AT+VERSION Report the module's version number
AT+NAMEname Change the Bluetooth ID to name (maximum 20characters).
AT+PINnnnn Change the PIN to nnnn, which must be a four digit number.
AT+BAUDn Change the baud rate. Use one of the following values forn:
2: 2400bps
3: 4800bps
4: 9600bps
5: 19200bps
6: 38400bps
7: 57600bps
8: 115200bps

One tricky aspect of sending these commands is that the Bluetooth module has a very short timeout, so all the characters in a command must be entered really quickly. The safest way to get the entire command in time is to type it in a text editor window and then use copy/paste to send it really fast.

If your Raspberry Pi session is local, then there is no clipboard support unless you work inside the X environment, so you will need to run startx and then open a Terminal window. If you are using a remote shell over the network then you can use the clipboard in your host operating system.

To send the commands we can use minicom. So let's fire it up one more time:

$ minicom -b 9600 -o -D /dev/ttyAMA0

Note that it isn't necessary to have a connection to do this, so you can do this while the Bluetooth module is in its blinking state.

You now need to use any method to get the string AT into the clipboard, and then hit paste inside the minicom window to send the command to the module.

When you send AT the module should respond with this in the minicom window:


If you get this response then you know that everything is all right. If you don't get a response then for some reason the Raspberry Pi is unable to communicate with the Bluetooth module.

When I send AT+VERSION to the module I get the following response:


To change the baud rate to the fastest rate of 115200 we need to issue the command AT+BAUD8, and the module will respond with:


Because the baud rate was changed now the communication will break, and we will need to exit and restart minicom with the updated speed:

$ minicom -b 115200 -o -D /dev/ttyAMA0

To change the name of the module to MyBT we must issue the command AT+NAMEMyBT, and the module will respond with:


And to change the PIN to 4321 the command is AT+PIN4321 and the response from the Bluetooth module will be:


Note that when the name and/or the PIN change the module requires a power cycle for the changes to take effect.

Also don't forget that if you change the baud rate and later want to reestablish the serial console you will need to change the two config files to reflect the new baud rate you have selected in the Bluetooth module.

HC Serial Bluetooth Products User Instructional Manual

Mrunali Bawankar

Mrunali Bawankar