Sunday, June 12, 2011

Arduino communicating with PC via Bluetooth

I like arduino because it has almost limitless potential. One of few a things that I hate is that when you want to control the arduino it has to be connected directly to the PC via USB.

So I’ve decided to buy some hardware to make my arduino communicate with PC wirelessly. There are few options how to achieve that. You can either use Bluetooth or Wi-Fi. With Wi-Fi You’ll be using XBee radios. There are few versions of them and they the cost about 30 dollars. But you will also need an arduino XBee shield and XBee usb dongle. So the whole price is about 70 dollars if you’re lucky. Or you can use Bluetooth. There are few options. You can use BlueSMiRF which is pretty expensive or any other Bluetooth modem. I have used really cheap one from eBay. But this Bluetooth modem was in XBee form. So I’ve also bought arduino XBee shield. After you assemble it you have to move switch on a Bluetooth modem to AT position.

Next tricky thing is connecting arduino to PC. Your PC has to have some Bluetooth device that supports Bluetooth serial port communication. Then upload this sketch to arduino :

const int ledPin = 13;
int value;    

void setup() {
  pinMode(ledPin, OUTPUT);

void loop() {
  if (Serial.available() > 0) {
    value =;
    if (value == 'H') {
      digitalWrite(ledPin, HIGH);
    if (value == 'L') {
      digitalWrite(ledPin, LOW);

Then unplug arduino from PC and put in 9V battery. Search for Bluetooth devices and you should find your device (mine is called WIDE_HK) select pair and then connect. Then just turn on some terminal app (puTTy, Arduino IDE….) connect it to serial port of your Bluetooth device and send it H to turn it ON or L to turn it OFF.

Video :

No comments:

Post a Comment