Cheap 2-Way Bluetooth Connection Between Arduino and PC

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.

2-Way Bluetooth Connection Between Arduino and PC

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 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);
}

[box color=”#985D00″ bg=”#FFF8CB” font=”verdana” fontsize=”14 ” radius=”20 ” border=”#985D12″ float=”right” head=”Major Components in Project” headbg=”#FFEB70″ headcolor=”#985D00″]

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

[/box]

For more detail: Cheap 2-Way Bluetooth Connection Between Arduino and PC


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top