Cheap 2-Way Bluetooth Connection Between Arduino and PC

 by techbitar
Featured
bluetooth-module.jpg

INTRODUCTION

In the guide, I will explain how I managed to send data back and forth between a PC and Arduino via a cheap Bluetooth HC-05 transceiver, which can be found for less than $10 on ebay with the breakout board. The version I have used in this project does not have a breakout board so it's little cheaper but  more difficult to solder.  I strongly recommend buying the module with the breakout board. This Bluetooth transceiver basically acts as a generic serial COM port.

The PC to Arduino Bluetooth serial connection can be useful in many applications such as controlling servos, motors, and writing to LCDs. The Arduino to PC connection can be useful in applications where the Arduino reads sensors then pass their values  via serial Bluetooth to a PC for processing. The distance for this transceiver is about 30 feet or so but it really depends on many other variables. This is ideal for indoors projects. 

The only downside of this cheap Bluetooth transceiver is the absence of headers which means you have to solder at least 4 wires. Then there's the absence of power LED as well as no TX/RX LEDs. I did not consider these features a necessity but some of you might want to pay more and get an enhanced version of this transceiver with all of these features.


The Bluetooth serial module I bought has the following specs:

-- Default COM setting: 9600, N, 8,1
-- Default Password/pairing code: 1234.
-- Supports the AT command to modify the baud rate, device name, passkey, master/slave, etc.
-- Supports baud rates 2400 -1382400.
-- Based on the CSR Bluetooth chip BC417143
-- Bluetooth specification v2.0 + EDR
-- Power supply: +3.3VDC 50mA
-- 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
-- Size: 26.9mm x 13mm x 2.2 mm.
-- Working temperature: -20 ~ +75 Centigrade
-- Dimension: 26.9mm x 13mm x 2.2 mm

CREDITS

During my research, I have benefited from many projects on this and related topics. I have listed them in the references section.

RELATED PROJECTS

1) In a previous project, I used a Pololu Wixel and an Arduino to control a robot remotely from a PC terminal. Here, I will show similar data exchange functionality but without the robot.

2) I also hacked the RF system of cheap wireless car toy and used the Arduino to transmit signals.


Step 1: The parts list

HARDWARE

-- Arduino Uno (R2) or clone.
-- Bluetooth serial transceiver connected to Arduino. I got one from Ebay with the BlueCore4 chipset. Search Ebay for Wireless Bluetooth Transceiver Module RS232 / TTL.
-- Bluetooth USB dongle to be connected to PC. I used an old MSI pc2pc Bluetooth as well as a Bollionton Bluetooth USB dongles and both worked fine. 
-- The 1.2K Ohms & 2.2K Ohms resistors will be used as voltage dividers to drop the Arduino's 5V to about 3.3V. You can substitute these with 10K Ohms & 20K Ohms resistors. If you know how to calculate voltage dividers, feel free to use other values for your resistors. 
-- Breadboard and jumper wires.
-- Power source. I used a 9V battery.
-- Any PC that supports Arduino IDE will be needed to program the Arduino microcontroller. 
-- Most PCs and  smartphone w/Bluetooth and a terminal emulator can be used to control the Arduino. 

SOFTWARE

-- Windows 7 64-bit. But this should work on other platforms supported by the Arduino IDE.
--  Arduino IDE 1.0
--  Tera Term Pro  terminal emulator but other similar emulators should work.
-- Tera Term by the original author of the software

Step 2: Load the Arduino test sketches

Arduino.jpg
NOTE: When uploading sketches from the Arduino IDE to the Arduino microcontroller, make sure your Bluetooth transceiver TX pin/wire is not connected to the Arduino's RX pin (pin 0) . Else, this may prevent your PC from sending sketches to the Arduino microcontroller.

Check the video to see how these demo sketches work. 

I have two Arduino test sketches. The first one is a "send test." The Arduino microcontroller sends numbers to the PC over serial Bluetooth. So if you have a terminal emulator running on your PC, such as Tera Term, you will see a list of numbers rolling down your emulator's screen.

I have done almost no error trapping in my code to keep the code clear and simple. I trust the developers will add it per their requirement. 

The second Arduino test sketch is a "get test." If you type 1 on your keyboard, from the terminal emulator application such as Tera Term, the Arduino's pin 13 LED will turn on. If you click 0 on your keyboard, the LED will turn off.

//////////////////////////////////////////////////////////////////////////////////
// REMIXED BY: TECHBITAR (HAZIM BITAR)
// LICENSE: PUBLIC DOMAIN
// DATE: MAY 2, 2012
// CONTACT: techbitar at gmail dot com

int counter =0;

void setup() {
  Serial.begin(9600); 
  delay(50);
}

void loop() {
  counter++;
  Serial.print("Arduino counter: ");
  Serial.println(counter);
  delay(500); // wait half a sec
}

//////////////////////////////////////////////////////////////////////////////////

// REMIXED BY: TECHBITAR (HAZIM BITAR)
// LICENSE: PUBLIC DOMAIN
// DATE: MAY 2, 2012
// CONTACT: techbitar at gmail dot com

char INBYTE;
int  LED = 13; // LED on pin 13

void setup() {
  Serial.begin(9600); 
  pinMode(LED, OUTPUT);
}

void loop() {
  Serial.println("Press 1 to turn Arduino pin 13 LED ON or 0 to turn it OFF:");
  while (!Serial.available());   // stay here so long as COM port is empty   
  INBYTE = Serial.read();        // read next available byte
  if( INBYTE == '0' ) digitalWrite(LED, LOW);  // if it's a 0 (zero) tun LED off
  if( INBYTE == '1' ) digitalWrite(LED, HIGH); // if it's a 1 (one) turn LED on
  delay(50);
}

Step 3: Wiring the Arduino + Bluetooth transceiver

WARNING: MY BLUETOOTH MODULE OPERATES AT +3.3V DC. THE ARDUINO UNO IO PINS OUTPUT 5V. SO AVOID CONNECTING THE ARDUINO 5V OUTPUT PINS TO THIS TRANSCEIVER WITHOUT A VOLTAGE DIVIDER.

However since the Bluetooth pins output 3.3V, this won't hurt the Arduino pins which tolerate 5V and will treat a 3.3V signal from the Bluetooth serial transceiver as a logical high. This is why I did not use a voltage divider for the connection between the Bluetooth transmission/TX pin (rated 3.3v) and the Arduino receive/RX pin 0 (rated 5V.)

START WIRING

1) Solder 4 wires to the Bluetooth module: TX, RX, GND, Vcc
2) Assemble the voltage divider. I have lots of photos to help with this step.
3) Wire the Bluetooth module to the Arduino Uno according to this:

Bluetooth TX  -----> Arduino Uno RX (Pin 0)
Bluetooth RX  -----> Arduino Uno TX (Pin 1) via the voltage divider!
Bluetooth GND -----> Arduino GND pin
Bluetooth Vcc  -----> Arduino 3.3V pin but NOT the 5V pin. 

4) Power the circuit. I used a 9V battery.

Keep a mobile phone or a Bluetooth device handy to detect whether your Bluetooth transceiver is available.

At this moment, your Bluetooth serial transceiver should come to live and other Bluetooth devices should see it. If you don't see it, check the wiring again. 

My Bluetooth serial transceiver has a default name of HC-05 and a default code of 1234 and speed of 9600. Check your vendor documentation for your devices name and password/pairing code.  You can change all these defaults with the AT commands.

5) Plug the Bluetooth USB dongle into your PC and move along to the next section.

Step 4: Set up your PC for serial Bluetooth communication

When you insert the Bluetooth dongle into the USB port of your PC, Windows will install the necessary drivers automatically. When it's done, it will display a system message stating the installation was a success.

You will then see the Bluetooth icon in your system tray or on your desktop. Click on it to see a menu with a number of options such as Show Bluetooth Devices. Click on it and follow the slides.

Select Add Devices or Show Bluetooth Devices. 

If your Arduino Bluetooth serial transceiver is wired properly, your device name should show up on the list. Click on it and then click Next.

You will be prompted to enter your Bluetooth devices' pairing code/password. The default for most Bluetooth devices is either 1234 or 0000.  Click Next. 

If the pairing is successful, you will see a system message saying so. 

Now, both your PC's Bluetooth and the Arduino's Bluetooth are connected as if by serial cable. 

Run Tera Term on your PC (or any similar terminal emulator) and select the COM port number specified by the pairing. 

FORGOT WHICH COM PORT?

If you forgot the Bluetooth COM port used for the paired Bluetooth transceivers, right click on the Bluetooth icon on your System Icon area and select "Show Bluetooth Devices." You will see a list of Bluetooth devices.  

Right click on your Bluetooth device and select "Properties."

Then click on the "Services" tab. There you will see the COM port number. 

When you can't make a connection/pairing even though you are certain your Bluetooth devices are running normally, delete your Bluetooth device and start the process from the top. That seems to reset the connection. 

RUN TERA TERM

Once the pairing is done, run Tera Term to start communicating with your Arduino. Tera Term will prompt you to pick either Serial or TCP/IP. Select Serial and make sure Tera Term shows the COM port number from the previous steps. Also make sure the settings are the same for both Bluetooth serial modules. In this case: 9600, N, 8,1

If you have uploaded the get test sketch, then type either 1 (one) or 0 (zero) to turn pin 13 LED on the Arduino on or off. If you uploaded the send test sketch, you will see a growing list of ascending numbers on the Tera Term screen sent from Arduino over serial Bluetooth.

Step 5: References

Special thanks to my good friend and top notch maker Jafar Qutaineh for his input and to the developers of the many helpful Bluetooth projects that I used as a foundation for this project such as the ones listed here:

Wireless communication with PC and Arduino board using Bluetooth
http://arduino.cc/playground/Learning/Tutorial01

Androino! Control an Arduino from your Android device using a cheap bluetooth module.
http://www.instructables.com/id/Androino-Talk-with-an-Arduino-from-your-Android-d/

how to Control arduino by bluetooth from (PC, pocket PC PDA)
http://www.instructables.com/id/how-to-Control-arduino-by-bluetooth-from-PC-pock/

USE THIS GUIDE AT YOUR OWN RISK
robocop.ultron says: May 4, 2013. 5:29 AM
thanks sir! It will help me a lot , but can hc-05 Bluetooth module sustain 4V of power supply ???
renefabri says: Apr 29, 2013. 12:37 PM
Thank you for the video. You helped me. You show how to add a new device in Windows, and at 5 minutes 25 seconds in the video, one can see that "Other Bluetooth Other" is replaced by "HC05 Bluetooth Other". With my system, there was no change. It stayed on "Other Bluetooth Other", and subsequently the device could not be added. So, You made me think my Bluetooth dongle is failing. I tried with another Bluetooth dongle, and, hurray, "Other Bluetooth Other" is changing to something else, i.e. "Linvor Bluetooth Other" in my case. And afterwards, everything is ok.
hurkankartal says: Apr 24, 2013. 11:00 AM
Hey, thanks for guide. It helped much enough! The only thing that I did not like is, I cant see com ports sometime. I don't know the reason why but when I unplug the power and give it again to the hc05 it becomes normal.
milan.your says: Apr 18, 2013. 2:44 PM
hello,
Thank you very much for the tutorial. I followed all the steps but i was not able to see the COM PORT number for my bluetooth (HC-05), there wasn't anything listed under "Service" inside the properties of the BT. Please suggest me what i can do next.

Thanks,
Milan
limbo says: Mar 27, 2013. 8:18 AM
Great guide. Thanks
cmagro says: Mar 22, 2013. 2:14 PM
The Problem I have is that I am sending it AT and the BT module SHOULD answer back with OK but nothing happens. If I use my mobile phone, I can see and connect to it easily!

The BT TX is directly going to the Arduino RX however the Arduino TX is going into a 10k resistor, and into the RX of the BT. From here, I connect 20k to ground.

So its like a potential divider, with RX of BT in the middle, 20k at bottom to gnd and 10k at top to Arduino Tx...

chanakyapm says: Mar 7, 2013. 12:56 PM
ianmcrv says: Jan 31, 2013. 2:20 PM
I just released my Android software BTInterface I've used this module with a backplane.
Lots of info on my site www.btinterface.com
Please take a look.

ian
jfenwick says: Jan 13, 2013. 6:40 PM
It turned out that I needed a 2.2K resistor going from the HC-05 TX pin to GND. I suspect the default state either had too much or too little voltage going to the Arduino RX pin.
jfenwick says: Nov 7, 2009. 6:24 PM
I'm seeing some strange behavior.
I'm using this HC-05 clone:
http://www.lctech-inc.com/Hardware/Detail.aspx?id=25662aa3-0517-4d3d-960e-ff261d5ef28c

I hooked up the electronics as shown in your diagrams, except I used an adafruit level shifter instead of resistors.
I'm using a Mac and I'm able to pair with the device.
When I run the sketch that sends counter data, I'm able to open CoolTerm, connect to the HC-05 serial port, and I'm able to receive the data.
However, when I try to run the program where you can turn an LED on with 1 or off with 0, it does not work!
What could I be doing wrong?
ssarantis says: Jan 3, 2013. 4:00 PM
Hello, when i use the resistor as voltage dividers i receive only random caracters on my computer and if i use it directly it works normal.. i get confused :/
zouzzouz says: Dec 28, 2012. 1:00 AM
plz i want some help i have bought an hc05 bluetooth module andhave done all the necessary wiring that you have done in the next steps but i am still not having any results when i am searching for the device from a mobile phone or any device. thx
diy_bloke says: Dec 11, 2012. 7:13 AM
Still dont have this working. My problem seems to be that when I have everything installed, communication over COM3, both the Arduino IDE as well as TeraTerm can't connect to that port because ' it is already in use' yeah, by the bluetooth module I would think, so how do I fix this? I have followed the ibble to the letter
diy_bloke says: Nov 21, 2012. 11:11 AM
I am quite unknowledgeable about what would be a master or a slave in Bluetooth, but as for now I am even unable to get any type of significant connection and I'd be glad if someone could offer some pointers/help

I have what I believe is the HC06 connected to my Arduino Rx ->Tx and Tx ->Rx
I have a bluetooth dongle on my pc. I easily establish a connection, at least that is wht my computer says, it recognizes the HC06 and comes back with teh device ' linvor'.

But that is it. I have a program running on my arduino at 9600 Baud that basically repeatedly sends the message ' test' to the serial port, but I get nothing on my pc (In the IDE serial monitor or a terminal program that is) and I keep having a flashing LED on my bluetooth HC06 module, whereas I understand it should go on uninterrupted when there is transmission.
What is it I do wrong?
yaly in reply to diy_blokeDec 7, 2012. 2:22 PM
I don't know about the led code thingie but right click on the bluetooth icon in the task bar, click open settings, select com ports tab from the top, click add, select outgoing check box, browse for the module and click ok, you should have a comport installing and close any arduino ide open and reopen it, select the serial port (eg: com 30) from tools drop down menu, now try the testing program again
diy_bloke in reply to yalyDec 11, 2012. 6:37 AM
Yaly
Your advice brought me a bit further, but not quite there yet.
I have a completly new Win 7 installed. It has bluetooth and it recognizes the module attached to my Arduino.
I follow your description, everything goes well and COm3 is selected as Outgoing (i.e. PC initiates)
I start up the Arduino IDE (also a fresh install)
I select COM3
suddenly get the message ' cant find com3' (or similar words)
I check... com 3 is still present as attached to the Bluetooth module
Any suggestions??


I actually seem to have asimilar problem in UBUNTU :-) there it is connected to rfcomm0 and though I change it in the conf file, I still cant select that, but I already would be ahppy if I got it to work under windows
diy_bloke in reply to yalyDec 8, 2012. 3:32 PM
Thanks, But I have no problem installing or finding the device/module or installing com ports, I just dont get anything into my serial monitor. I think what you describe is what I did (cant repeat right now, on Linux) and I have no problem connecting to other bluetooth devices, except this one.
My computer finds the module it hets assigned a com port, but I dont get anything on it

I guess I just have to try it again step by step when I am back on windows. On Linux now and the same problem
diy_bloke in reply to diy_blokeDec 9, 2012. 1:14 AM
I can ping the device and everything says it is connecetd, I see the LED change fron flickering to solid burning, but at least on Ubuntu the problem seems to be that the IDE can't see the rfcomm device (not even when i define it in preferences.con). Odd, I have no problem exchanging date with e.g. my phone
I'll just have to wait till I got windows installed again and try again, maybe I overlooked something
yaly says: Dec 7, 2012. 2:05 PM
slightly off-point: although its uno r2 the atmgea 8 (usb to serial ttl coverter) is 90 degrees oriented but mine is 45 degrees, weird but cool. My real question: what is the difference between HC-05 module and HC-03 module?
offtherails2010 says: Nov 17, 2012. 2:22 PM
Okay just thought i'd let you know that ive managed to get this all working as your awesome little test sketches have instructed !

I have no idea why this all started working as it should for me, i must have started from scratch building this circuit up on my breadboard well-over 30 times and now im finally getting the arduino counting onto terra term and also the pin-13 LED on/off sketch is working as it should !

Once again thanks for the instructable !!!
offtherails2010 says: Nov 17, 2012. 11:52 AM
Also the Counter-sketch comes up with similar jibberish and im so stuck now and dont know what else to do, ive wired it up several times from scratch following your guide but still get the same results from both sketches, please help ?

many many thanks in advance for any help
offtherails2010 says: Nov 17, 2012. 8:04 AM
Hi techbitar

thanks for the GREAT instructable - ive just dived into the Arduino world and loving it !

i have a few of these bluetooth modules, not sure about what firmware they are or if they are slave or master but thats not what i need help with lol !

Please would you be able to tell me why i keep getting a load of writing keep being sent to my terraterm monitor from the Arduino please?

the thing is, i have your Pin-13 sketch loaded up and its sending this stuff:
¿-¿ass
åë_¿¿!¿¿}-#!¿-#¿¿guw¿ac¿!¿¿!¿¿-¿ass
åë_¿¿!¿¿}-#!¿-#¿¿guw¿ac¿!¿¿!¿¿-¿ass
åë_¿¿!¿¿}-#

Im not quite sure what ive done wrong as ive connected it up as per your instructable and cant seem to get this sketch to turn on the pin-13 LED when i enter either 1 or 0 in terraterm because the Arduino is sending that above repeating line to my serial terminal !

Please please help !

i know this is an old post but ive got all this setup on my desk and it took hours to get this far, i would really appreciate some enlightenment on this if you would know whats going on here, please please help

Many thanks in advance !
gomibakou says: May 7, 2012. 7:42 AM
Notice these modules externally all looks very similar but the major diferences are in the firmware.

I resume the firmwares:

HC-05: master / slave mode, programmable via AT commands.
HC-06 (or Linvor 1.5): only slave mode
I think there is other HC-06 fixed for master mode, so, two different HC-06 firmwares and FIXED for master or slave: you can't change the mode.

HC-03 and HC-04 are industrial versions of the HC-05 and HC-06 firmwares.

Have this in mind before purchashing these modules because not all vendors are clear about this (i found some vendors that mixed all the firmwares in the description and at the end you don't know really what it is using -surely neither them know it xdD-).

The most common is HC-06 (linvor 1.5) firmware in slave mode.

So, double check this before buying if you intend to buy a master module.

I talk from my own experience ;)
uahmed3 in reply to gomibakouSep 19, 2012. 3:30 AM
exactly same happening to me. I have HC-06 and now can't enter into AT mode. though i have paired paired HC-05 as master and HC-06 as slave. but still no communication is found :(
any clue?
im_technick says: Sep 2, 2012. 1:22 PM
Is possible to make another of this and communicate each other?
techbitar (author) in reply to im_technickSep 17, 2012. 1:08 PM
I don't see why not.
subrata.s.du says: Sep 15, 2012. 9:20 AM
hi, whether if i use arduino bt(instead of Arduino Uno (R2) or clone), then should i have to use bt transceiver?? also give some clone models...

and also can u provide a circuit diagram about how to build a bt transceiver...bcz i cant afford to buy online.......thank you though for your post.
WABIX says: Aug 16, 2012. 3:53 AM
Could you connect 2 arduinos like this and have them talk to each other?
techbitar (author) in reply to WABIXAug 16, 2012. 7:10 AM
If you use the transceiver's AT command set I see no reason why you can't.
WABIX in reply to techbitarAug 17, 2012. 5:06 PM
Sorry, i'm a noob so i have no idea what your talking about.
dshookowsky says: Jun 28, 2012. 8:13 PM
I barely passed electronics in college, but based on some online voltage divider calculators, you can recreate this with any three identical resistors. Place the 3 resistors in series and R1 becomes the 1.2k resistor and R2 and R3 replace the 2.2k resistor. I've successfully done this with 3 33 ohm resistors.

Thanks for the instructable. I visited it while connecting a Bluetooth chip to a parallax boe bot shield for arduino.
techbitar (author) in reply to dshookowskyJun 30, 2012. 11:59 AM
you're welcome. You can also use a zener diode to drop the voltage.
pictux says: Jun 28, 2012. 1:36 PM
Per quelli che sono italiani, ecco una guida completa:
http://arduino.cc/forum/index.php/topic,104903.0.html

Parla di moduli HC05 e HC06, in particolare:
- connessione hardware
- programmazione AT
- connessione seriale BT (pc <-> arduino)
- applicazione base per Android (fatta con AppInventor)
- breakout pcb (disponibili i file eagle)
- esempi vari

-------------------------

for those who are Italian, here is a complete guide:
http://arduino.cc/forum/index.php/topic, 104903.0.html

He talks about HC05 & HC06 module, particulary:
- Hardware connection
- AT Programming
- BT serial connection (pc <-> arduino)
- The basic application for Android (made with AppInventor)
- Breakout pcb (Eagle files available)
- Various examples
dunnos says: May 14, 2012. 12:45 PM
would it be possible to use the arduino IDE terminal for this?
techbitar (author) in reply to dunnosMay 20, 2012. 1:03 PM
Why not.
Foxtrot70 says: May 5, 2012. 7:32 AM
Excellent Instructable! The range could be increased by using a salvaged 2' Satelite Dish removing the LNB then, modifying the Bluetooth board to have an external antenna jack SMA type or smaller, placing the board at the dish in a protective project box. A Bowtie element tuned to the Bluetooth frequency then placed at the focal point of the dish. You would now have a long range wireless RS-232 link.
noonv says: May 3, 2012. 11:17 AM
Detailed article about this module (on Russian) - http://robocraft.ru/blog/electronics/587.html
and library management module with AT commands - https://github.com/RoboCraft/Bluetooth_HC05
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!