Introduction: Cheap 2-Way Bluetooth Connection Between Arduino and PC

About: Did I unplug the solder iron?
UPDATE

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

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.
https://www.instructables.com/id/Androino-Talk-with-an-Arduino-from-your-Android-d/

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

USE THIS GUIDE AT YOUR OWN RISK