How to control arduino board using an android phone and a bluetooth module

Picture of How to control arduino board using an android phone and a bluetooth module
In this tutorial you'll learn how to use a bluetooth module and MIT's app inventor to create a wireless serial link between an android phone and an arduino board.

Here is a short video showing an example app I created. I'll describe how to do the wiring, write an arduino sketch that can accept basic commands and send them and how to write the app itself. I asume you're already familiar with some of the basics, you made a few arduino projects and are familiar with the arduino IDE. If you have attempted serial communication with the arduino board everything should be fully comprehensible. If you have any problems or questions feel free to ask them in the comments section.

...and here is an example of receiving the data from the arduino board on the mobile. The temperature sensor connected to the arduino board is a ds18b20 sensor. Just to show how awesome app inventor is I added text to speech functionality - the app says the temperature every 15 seconds. The arduino code and the app is described in more detail in steps 4,5 and 6.
Remove these adsRemove these ads by Signing Up

Step 1: Wiring & part list

Picture of Wiring & part list
The circuit is as simple as it gets so you probably already have most of them.

You will need:
- arduino board
- bluetooth serial module (I used a btm222 module on a breakout board with an inbuilt regulator )
- an LED
- resistor (100ohm)
- wires
- breadboard

The only problematic part here is the bluetooth module. There are different modules all over the internet so be sure you check the pinout in the datasheet of the one you get as it can differ.

Also notice that there are two general classes of bluetooth modules:
Class 1 has range of about 100 meter (300 feet)
Class 2 has range of about 10meter (30 feet)
In case you're wondering they are entirely compatible and you can only get 100 meter range if both of the devices (ie the mobile and the serial module) are class one. If one of it is class 1 the maximum range is lower.

The bluetooth serial module I got has the following pins from left to right (ground, RX, TX, not connected, VCC). Obviously ground and VCC goes respectively to ground and +5V pin on the arduino board. Since we will be receiveing the data through the module and then in turn sending it to the arduino board we only need to use the TX pin on the module. Run a wire from that pin to the RX pin on the arduino board. The Led is controlled through PIN 2 on the arduino.

kodagames2 days ago


Im new to app inventor. Can you share the .aia file? For turning on and off the LED I tried to figure out how to download the files from the link you provided but dont know what to do with the .blk or .scm files.

Also Im extremely grateful that you have provided this tutorial and greatly appreciate you taking the time to put this together! Thank You!

Nilanj8 days ago

thanks for this

its not working on my HC-6

ted is not turning on or off.

ivver17 days ago

Thank you! And just to say, for controlling some motor or car, you have one great finished application on Market (google play): Bluetooth RC Controller

alacosta22 days ago

hi just to say I have found this project very useful and say thank you. My problem I would like to change / edit the source code for the temperature project. However I given several possibilities of files to down load / import, what ever I try I get error on

MIT's app inventor not an .aia file. please advise how I get this file to edit

Thank you


titi311 month ago

hi Kerimil, i already download your app about bluetooth for arduino..
i want to ask about the bluetooth from the android app, what kind of bluetooth can connect to the android? just bluetooth from arduino or other bluetooth from handphone and PC? thankyuu Kerimil..

Thank you Kerimil, the arduino code and app works perfectly for me. I am using the DHT22 sensor connected to digital pin 2. Thank you for sharing your work.

nero7772 months ago

Thanks , this post was very useful for me :) I managed to send data to the LCD screen by developing an app using your source code thanks alot.

I just have one question , now I'm trying to receive the data from the arduino and display it in a label so for example I want to print hello from this command in arduino Serial.print("Hello"); in a label . But the receive text function in the MIT software only sets it as bits not characters so I'm not able to receive it .

here is my work

I would be gratefull if you can hep me with this

Screenshot 2014-02-18 17.14.36.png
kerimil (author)  nero7771 month ago

You have to specify number of bytes to receive in bluetoothclient.receivetext

Put there 0 (zero) and it will work just fine. Just remember to send a message with a delimiter byte.

Appinventor has help dialogs built in. If you keep you mouse pointer on any block or even part of it, a message will pop up saying what it does and how to use it. Try this out with the bluetoothclient.receivetext block and number of bytes ;-) you'll see why

Hi Kerimil. I am using the HC-06 serial bluetooth module. I was able to connect the app to the module and I succesfully uploaded the arduino code. I connected the ledPin to pin 7 on the arduino uno, yet the LED did no come on. Please where could the problem be? And if it has to do with the bluetooth module where can I purchase the bluetooth module you used online? Thank you.

Hi Kerimil, I got the LED working now. I upgraded the android from the 4.3.0 it was to 4.4.2 and the app works perfectly turning the LED ON and OFF, The voice commands also works well. Thank you.

Nirav0081 month ago

can I use HC-05 Bluetooth module for this project.

calou11 month ago

j'ai un problème, j'utilise un récepteur bt avec une vitesse de 9600 et la led ne s'allume pas, faut-il du 115200?

takkan2 months ago

hello, I am new to the Arduino circle and picking up things as I go along. recently I combined a sketch of the push button and the push button stop watch to make me a counter (sensor-relay switch counter) and a push button stop watch. All I want to do now is have a customized screen to display the results of this. so far I have tried PLX-DAQ and Gobetweno to do the same(both lacking the refinement and the flexibility). My question to you is, is it possible to have an app which is efficient enough to not only display this information in a legible format but also is able to import information from my network neighborhood to ingrate into the app.

I will be highly obliged if you could guide me in the best direction as I have no more resources left to refer to neither do I have any more ideas streaming in my mind

jblakes343 months ago

Can I use this Bluetooth connection to stream video from a device similar to the Parrot A.R. Drone, or would I need a Wi-Fi or ethernet connection for that? Any suggestions on how to do that? Thanks for the help.


kerimil (author)  jblakes343 months ago

If I were you I'd use wifi to get images from the device. If the device acts as an IP cam and supports jpg mode it can be done. Check this - it might be helpful ->!topic/appinventor/Z30eETu0B1s

bjamose6 months ago
i wont to do this project using the wifi
the change is just in the bluetooth module or i need other
choconog bjamose3 months ago

use ethernet shield

bjamose bjamose6 months ago
please help me
kerimil (author)  bjamose6 months ago
Obviously you need other things. check my video 'arduino temperature monitor' - you could combine that method and an example arduino sketch 'wifidatastreamDownload' that comes with a xively library. Xively was formerly known as Cosm but it's essentially the same - you'll have to change some URLs in the example app.
sam_12343 months ago

Dear Kerimil

First of all I would like to thank-you for explaining in such easy words that a lay-man with little knowledge of networking and Programming know how might be able to grasp this project easily .I am with a technical background and a hobbyist I want to kick start my Arduino projects this week the simpler ones first and then move to this one which is my main goal ,so friend in this project I wish to ask if it was possible to connect a Relay module which is readily available on ebay these days instead of a LED as my Aim is to control 3-4 home appliances by virtue of this project.Hope to hear from you soon.

Regards & best wishes


kerimil (author)  sam_12343 months ago

sure not a problem - just use a relay module istead of an LED

sam_1234 kerimil3 months ago

Thankyou Kerimil

I am all set but before taking a big step I will be doing the miniatures like interfacing LCD etc :D then learn a bit of C programming did that 7 years back now need to get into the groove and final decent would be this cool project Thanykou for the speedy reply I would be looking forward to your guidance if stuck which I am sure I will as always :D Cheers

villadsen17 months ago
So im trying to use your program just to turn on and off the LED on the arduino mega 2560.. The one connected to pin 13. So i changed the ledPin to 13 but then i get this error: avrdude: stk500v2_ReceiveMessage(): timeout
what is going on, can you help me?
Tnx very much
i started my first arudino project because i saw your app.
I had the same problem.....
Here is a link to the fix, After I unplugged the RX pin the sketch uploaded flawlessly... then I plugged it back in and it works great.
kerimil (author)  glennballen3 months ago

When there's anything attached to TX/RX pins you can't use usb to communicate with the board - disconnect the module, upload code and then wire it again

sankha874 months ago
I,m using HC 06 bluetooth module.baud rate selected as 9600.
app installed in sonyericsson xperia ray. led on and off doesnt work. only blutooth pair and connected together.

after connecting Bluetooth, when I press the voice commands button in app it gives error.
"connection problem"
yellow color circle with triangle sign mark.
I would be much grateful if you help me.
pls explain the problem
kerimil (author)  sankha874 months ago
Hc06 modules can either be slave or master and you can't change it. Normally they are sold as slave devices. Since the app (phone) is set as the client it won't work.
kerimil (author)  kerimil4 months ago
client meaning slave
sankha874 months ago
after connecting Bluetooth, when I press the voice commands button in app it gives error.
"connection problem"
yellow color circle with triangle sign mark.
I would be much grateful if you help me.
pls explain the problem
kosidinma4 months ago
Hi, please how can i write a code block that receives more than one value from the arduino and display both on the phone; for example, if i want to receive temperature and battery voltage and display both on the phone at the same time? thank you.
kerimil (author)  kosidinma4 months ago
arduino code:

Create an app that looks for a coma "," and splits the string received from arduino into two - the first part is value x the other value y. Everything you need is in text blocks - when you move the cursor over blocks you'll see what they do
kosidinma kerimil4 months ago
Thank you so much
yangness4 months ago
Can you make an app that receives coin reading from coin acceptors?
kosidinma4 months ago
If I might ask, why did you put -1 as the number of received bytes in the bluetooth receive text block ?
kerimil (author)  kosidinma4 months ago
Move the cursor above the block it will display a help box - very very useful feature. If you set it to less than 0 it reads until it gets a delimiter byte
kosidinma kerimil4 months ago
Please what do you mean by delimiter byte?
kerimil (author)  kosidinma4 months ago
It's a byte that you send to mark the end of transmission. You can set it in appinventor. In this particular example app that we're talking about the arduino sends data so it's set to accept a carriage return that arduino's Serial.println command sends. Google ascii chart and look for number 13 you'll see that it's carriage return. Yeah I know it's confusing at first.
kosidinma kerimil4 months ago
thanks for the quick reply; i'll look into it
kosidinma5 months ago
Since for receiving the data through the module and sending it to the arduino board we connect the TX pin on the module to the RX pin on the arduino board (in the LED part), does that mean that we connect the RX pin on the module to the TX pin on the arduino board to receive the temperature from the arduino (in step 4)?? And can both these connections (RX module to TX arduino and TX module to RX arduino) be done together??
kerimil (author)  kosidinma5 months ago
yeah, obviously they can be done toghether... the key issue here is that you connect TX pint to RX pin and the other way round... since the module is sending data out and the arduino is receiving it and when it's sending it the module has to receive that.... i know it's kind of obvious but you wouldn't believe how many private messages I got askign about it

Get More Out of Instructables

Already have an Account?


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!