Introduction: How to Control Arduino by Bluetooth From (PC, Pocket PC PDA)


I wanted to make it possible to control an arduino board from my phone.
So that I could control other devices.
the easiest way seemed to be using bluetooth.

but when I received the parts needed I found it want quite as simple as I had hoped.
And after looking on the Internet I didn't find much information to help.

so I have decided to write this guide to help other people that are thinking of doing the same thing. 

Step 1: Parts Needed


1 arduino board ( I used the duemilanvoe 328)
1 bluetooth serial board ( I used the sparkfunbluesmirf)
some pieces of wire
1 led
A computer with bluetooth or a usb bluetooth adaptor.
A pocket PC with bluetooth

Software needed

the arduino enviroment software
and some serial terminal software ( I used putty)

Step 2: Wiring It All Up

I linked the cts1 to the rts0 on the bluetooth module.
then I wired the tx on the module to the rx on arduino
the rx on the bluetooth to the tx on arduino

I protected the bluetooth module by sealing it with heatshrink.

I then connected +5v and 0v to the bluetooth  board from arduino and supplied the arduino board with 5volts.

and pluged an LED in to socket pin 13 and ground to test it.

as shown.

Step 3: Loading the Software

Before I connected the board using bluetooth. I had to load some code on to the arduino board.

The easiest way to do this is to open the arduino enviroment software program and connect the board to a computer using usb.

then go to the tools tab and make sure the correct arduino board and usb ports are selected.

then up load this code on to the board.

this code will allow you to switch on and off the led by pressing 1 for on and 0 for off.
from your terminal.

/*
simple LED test
*/

char val;         // variable to receive data from the serial port
int ledpin = 2;  // LED connected to pin 2 (on-board LED)

void setup()
{
  pinMode(ledpin = 13, OUTPUT);  // pin 13 (on-board LED) as OUTPUT
 
  Serial.begin(115200);       // start serial communication at 115200bps
 
}
 
void loop() {
  if( Serial.available() )       // if data is available to read
  {;}
    val = Serial.read();         // read it and store it in 'val'
 
  if( val == '0' )               // if '0' was received led 13 is switched off

  {
   digitalWrite(ledpin, LOW);    // turn Off pin 13 off
delay(1000);                  // waits for a second  
Serial.println("13 off");
  }

if( val == '1' )               // if '1' was received led 13 on
 {
    digitalWrite(ledpin = 13, HIGH);  // turn ON pin 13 on
    delay(1000);                  // waits for a second
    Serial.println("13 on");
  }
}



Step 4: Connecting Over Bluetooth on the PC

the next step is to connect the arduino board using bluetooth.

disconnect the arduino usb cable and connect up the bluetooth module.

power the arduino board. and the red led on the bluetooth module should flash.

now open the bluetooth control panel on your pc this can be opened from the system control panel or from the icon in the bottom right of your desktop.

you will now have to add a new bluetooth device.
click my device is set up and ready to be found

then on the next screen to will see firefly-E754 or something similer. click next

on this screen select use the passkey found in the documentation and enter 1234.

on the last screen you will see which ports your computer assigns my computer set com11 for outgoing and com12 for incoming.




Step 5: Controlling From a Terminal in Windows

the next step is to connect to your arduino board using a terminal.

I used putty.

I selected the serial option and set the com port to 11 to match the bluetooth settings that my computer set.
then I set the baud rate to 115200. to match the baud rate in the code.

and clicked open

then the terminal window opens and the led on the bluetooth module turns green.

now when I press 1 the led will light up
and when I press 0 the led turns off.




Step 6: Controlling From a Pocket PC PDA

the priciples are basicly the same as connecting using a PC

On the pocket pc open the bluetooth manager and serch for new device.

when you see the Firefly-E754SPP connect to it.
enter the passkey 1234

then open pocket putty.

select serial put in the com port used on my PDA it's com6. set the baud rate speed to 115200.
and click open.

and the terminal should open the led will go green on the bluetooth module. and you will be able to send commands to your arduino.






Comments

author
omar+mansour made it!(author)2016-05-11

i am tring to connect an android app with bluetooth hc05 but this message appear "unable to connection ,is the device turned on ?"

how can i fix this

thank you

author
muneebs7 made it!(author)2017-02-25

first go to the bluetooth settings on your phone and connect to the reciver, put in the password(1,2,3,4) then go to bluetooth app

author
Fritzy28 made it!(author)2016-01-15

Hello, i have a noob question,to use the HC05 must i go through any initial set ups? i followed you intructions, my pc already have a built in bluetooth. i connected to the HC-05 uploaded the code onto my arduino, then used a separate power source for the Arduino . i made sure to connect to the sending COM and when i try to create a connection from arduino to BT it fails . gives me avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x59

author
KitsuneBlade made it!(author)2016-06-21

Hey!

This problem is really common, and easy to fix! :D This usually comes up when you're using a board other than the one selected in the arduino program. Just go tools>board>and select your board! :D

author
KitsuneBlade made it!(author)2016-06-21

Hey!

This problem is really common, and easy to fix! :D This usually comes up when you're using a board other than the one selected in the arduino program. Just go tools>board>and select your board! :D

author
FatimS1 made it!(author)2016-06-06

Can anyone give me code for Bluetooth connection to the arduino device ????
I need it urgently
In C++, C#

author
JorgeF22 made it!(author)2016-01-28

It worked, thank you

author
albertstc01 made it!(author)2015-09-16

Hi I am trying to get hold of the PocketPutty application for my HTC Mantle. The downlink link on the SurgeForce and other websites doesn't connect to the original PocketPutty site any more. It seems to be taken over by a Japanese owner with unrelated material to PocketPutty. Also other web sites claiming to have the application for download have just filled up my computer with unwanted maleware. Does anyone know where there is a safe down load for the application. It is open source under the BSD licence so redistribution could have been stored and made available from other websites. Regards in advance albertstc01

author
malikahakimi made it!(author)2015-10-07

I have a question :

how to get the data from bluetooth module by arduino?

author
malikahakimi made it!(author)2015-10-07

I have a question :

how to get the data from bluetooth module by arduino?

author
albertstc01 made it!(author)2015-09-16

author
sonic656 made it!(author)2012-06-30

Hi. Thx for your script! But it wasn't working for me for the first time. I used Bluetooth SPP, the best app i think, for android to play with Arduino nano serial port. I needed to edit your code. Now it works great!

My code:

char val; // variable to receive data from the serial port
int ledpin =13; // LED connected to pin 13 or onboard LED

void setup()
{
pinMode(ledpin, OUTPUT); // set ledpin as OUTPUT
Serial.begin(9600); // start serial communication at 115200bps

}

void loop() {
if( Serial.available() ) // if data is available to read
{
;
}
val = Serial.read(); // read serial and store it in 'val'

if((val == '0' ) || (val == 'off')) // if '0' or 'off' was received ledpin is switched off
{
digitalWrite(ledpin, LOW); // turn ledpin Off
Serial.println("ledpin off");
}

if((val == '1' ) || (val == 'on')) // if '1' or 'on' was received ledpin is switched on
{
digitalWrite(ledpin, HIGH); // turn ledpin ON
Serial.println("ledpin on");
}
}

author
AndersonW1 made it!(author)2015-08-14

Yes, you are right. I had trouble connecting using 115200 baud. Thanks for posting.

author
yusefHD made it!(author)2015-04-21

Hey Simon,

The folks at Upverter made an infographic to help readers in finding a bluetooth module. This could be a useful resource for a future project!

You can find the link down below.

http://blog.upverter.com/post/102541328427/bluetooth-module
author
thebluesman007 made it!(author)2014-12-23

I used ArduDroid and the circuitry given on the website TechBitar.

Here is the video Link!

https://www.facebook.com/video.php?v=10152676596932585&l=7117698860085934036

DSC_0003.jpg
author
tanzimmubarrat made it!(author)2014-09-29

author
Geniusdude made it!(author)2012-04-16

So what is the exact voltage at the terminals for the LED? I'd like to know this before I build to see if it will work for my application, thanks!

author
slaserj made it!(author)2014-07-19

2 year late reply, but if hopefully helpful to others reading this. The arduino works at a 5 volt logic level, meaning that if a pin is set to HIGH, or "on", it outputs +5 volts.

author
imadou1993 made it!(author)2014-04-15

Hello,

I am working on inte galileo compatible arduino board. And I want to command it using telnet (terminal). I succeeded at connecting my terminal to my board using telnet. But I want a program (instructions) to make my led turn on when I type the letter "Y" from my terminal. How can I make this work?

Thanks!

author
mmmatjaz made it!(author)2014-03-06

The bluetooth module does not work with arduino micros's RX and TX pins, but I does work with software serial. Any advice on that, anyone? I can't use software serial as I need the PWM pins for other stuff...

author
smaw51 made it!(author)2012-08-02

Check out http://beta.appinventor.mit.edu/ for an easy way to make an android app for use with your bluetooth communication arduino stuff. It is a pretty easy interface and free!

author
drmpf made it!(author)2012-09-19

If you don't want to do the Andriod programming,try my pfodApp. It handles all the Andriod side, You just code the Arduino device.

Think HTML replacement for micros. The Arduino is the micro-server and pfodApp is the micro-browser.

www.pfod.com.au has complete tutorial examples of controlling micro devices from Andriod with NO Android programming.

author
hectorbunny made it!(author)2012-05-06

Very nice project, but I have a doubt, this can receive and transmit data at the same time? or you have to stop receiving data to send data from your PC
Thanks

author
st_jimmy made it!(author)2011-04-02

hi,thanks for the instructable first of all.
i need to ask a few questions about connecting hardware.
1)why do we need to connect cts1 and rts0 ports?
2)why do we need to connect Rx on Arduino with Tx on BlueSmirf, and Tx on Arduino with Rx on BlueSmirf?aren't they supposed to be reciprocal?

thanks in advance

author
kool1zero made it!(author)2012-04-27

the cts1 and rts0 mean clear to send and ready to send. they tell the bluetooth module you're ready to receive data and when you're ready to send data.

and the Rx means receiving communication Tx means sending. so the send of the bluetooth module goes to the receiving of the arduino and vice versa.

author
javi_el_largo made it!(author)2012-04-05

Hi,
Today I was playing with my Arduino Uno and my old PocketPC (Dell Axim), I'm doing the same thing with a different approach: instead of using Putty, programming my Axim with Basic4PPC and I'm able to read/switch on/off any of the Arduino's digital pins, or read/write any of its analog pins. At first, I thought of using EVB (Embedded Visual Basic which I think is free) but handling bluetooth with it is very hard

Congratulations for your instructable and greetings from Spain.

author
agnivohneb made it!(author)2012-01-16

I just ordered my bluetooth module and after I hit purchase I realized I have no idea how to use this thing. You tutorial helped a lot. I will give it a shot as soon as it arrives :)

Thanks +Fav

author
leee2011 made it!(author)2011-11-20

Hi everyone, I bought a Bluetooth breakout from
http://www.ebay.co.uk/itm/1pcs-TTL-Bluetooth-Module-adapter-board-/270808764130?pt=LH_DefaultDomain_0&hash=item3f0d75cee2
Can this breakout be connected to my Duemilanove directly.
In my mind the arduino is 5V TTL logic, but the Bluetooth module is 3.3V TTL based.
Thanks in advance.

author
%7EREY%7E made it!(author)2011-10-27

Very Cool! Great Instructable!

author
aegidos made it!(author)2011-09-03

Hy Simon,

I like your post about the Bluetooth module.
Now I'm trying on my own to connect as you descibed in your howto using this module:

http://www.ebay.co.uk/itm/Arduino-Bluetooth-Module-Slave-Wireless-Serial-Board-/390333614711

I connected TX to RX and RX to TX and the power supply as well GND and 5V.
Pairing works very well and the BT module indicates that connection was established, after typing the "password" 1234 in.

Now i have difficulties sending data "1" to switch the LED on. That does not work.
The only difference from my module compared to yours is that i haven't connected the KEY and the STATE connector. It is descibed in the datasheet on ebay that they are not necessarily needed.

If i open serial port monitor in Arduino SDK and sending any kind of data to the arduino via BT no RX light is flashing - that confuses me right now.

Any idea what's going wrong there?
Help would be highly appreciated.
Greetz
Andi

author
Czayen made it!(author)2011-09-07

Hi Andi,

I have just received my BT module (from the same auction) and it works perfectly.
The problem is with Simon's code. I have modified it slightly and it works ok.
Here is the code: http://pokazywarka.pl/dfdzc7/

Regards
Tom

author
vishalapr made it!(author)2011-04-30

Will this USB transceiver work :

http://cgi.ebay.com/Bluetooth-Transceiver-Module-RS232-TTL-backplane-/390291743909?pt=LH_DefaultDomain_2&hash=item5adf3364a5

(My computer does have a bluetooth receiver 300 meters range)

Awaiting your reply...

This is a really cool instructable for people like me who are a bit ....

author
vishalapr made it!(author)2011-04-30

And one more question...
So we need to click enter after typing in (0 or 1 as in your program)

Thanks

author
mitman93 made it!(author)2011-03-13

Hello. I was wondering if it was possible to combine this with a usbhost shield? Do the two share any pins? And if so, would they interfere?

Thank you!

author
Chowmix12 made it!(author)2011-03-24

The usb shiekd doesn't use pins 0 and 1 (RX/TX) so it should be fine.) implementing code may be a little harder.

author
Magneto_Man made it!(author)2010-11-03


Great! thanks a lot! I used a standard serial Bluetooth adapter module and it works perfectly! :-)

author
Tchnclfl made it!(author)2009-11-16

You really shouldn't connect an LED like that without some form of resistor...Red LEDS, for example, are only supposed to run at about 2.5 volts MAX, and you're running 5v through that one.

author
Oxide made it!(author)2010-10-19

Pin 13 has an internal pull-up resistor: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1251513531/2

author
simon72post made it!(author)2009-11-17

Hi I agree with your comment about not connecting an led to a 5V supply with out a current limiting resistor.
But if you read the documentation on the arduino board there is a current limiting resistor on pin 13 for this purpose.

author
doby162 made it!(author)2010-07-12

this looks awsome! i currently have other projects going(which i plan to submit to instructables) but after them i might try to built a bluetooth controled robot. what kind of range do you get off that thing anyway? if i could controll the robot though out my house than that would be good enuf for me. also were would you get a bluetooth receiver? also some red leds wont even light off 2.5 volts, they very alot. ive even run one off a nine volt with no problem. ovcourse it was only producing 7 volts at the time...

author
javajunkie1976 made it!(author)2010-02-14

How would this work if I wanted to connect a wireless handheld controller to an 7 1/2" gauge locomotive and run it remotely? The current set up is too cumbersome with the cable and if track operations dictate the need to do some switching of cars on the track, walking alongside the locomotive gets to be a pain, especially with scenery and other trains.

author
joejoerowley made it!(author)2009-11-04

 Very Cool! Great Instructable!

author
Rorymi6 made it!(author)2009-11-04

Very interesting, might give this a go. I assume this a BlueSMiRF Gold?
Thanks
Rory