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.

1-40 of 125Next »

Do you think that I can use your setup for RX TX communication for a tank robot ?

I want to move the tank from my phone, by programming some buttons for left right on off for each track.

But I also want the tank to send some data to phone, like for example what is the value of pwm used for the motors, maybe also link a sonar sensor in order to check for obstacles.

Do you think it is possible to extend the setup you used for Bi-Directional communication, or do I need to use another application for Android for making custom buttons ?

Do you think that I can use your setup for RX TX communication for a tank robot ?

I want to move the tank from my phone, by programming some buttons for left right on off for each track.

But I also want the tank to send some data to phone, like for example what is the value of pwm used for the motors, maybe also link a sonar sensor in order to check for obstacles.

Do you think it is possible to extend the setup you used for Bi-Directional communication, or do I need to use another application for Android for making custom buttons ?

what if I'm using Bluetooth shield? How do I send characters from android app to arduino? I already know how to receive characters from app to arduino , but not how to send them.

agangwani1 month ago

can i use

HC05 Bluetooth Module Breakout Board

also please can someone list all the Bluetooth Module (like 222) which i can use? i couldn't get btm222 here at my place

Thanks :-)
jkurarin1 month ago

can you post the App Inventor blocks for the Text-to-Speech function? pls pls pls :)

This is great - An App Inventor 2 or Eclipse version would be good, too!

ovi08192 months ago

Hi! First sorry for my english.

Well i am using HC-07 BT module, i did all the steps, link the mobile with the board but when i press "Led On" nothing happens, but when i press "Led on" or "led off" el TX on the board, blinks.
Btw i changed the led

amyymoo2 months ago

well i have a question i'm working on a similar project but i need to control a temperature sensor using the same controlling app for the arduino , if you know anything about this topic , please give me an advice :)

drmpf3 months ago

If you don't want to do any Android programming, check out pfoDesigner

This free Android app lets you design your own Android menus and then generate the Arduino sketch that serves the menu, via pfodApp, and handles the users button presses. You only need to add the action code for each button command.

Here is an example menu designed by pfodDesigner. You can change the number of buttons, the text, the colours, the font size and style.

No Android programming required.

ruganattramn4 months ago

And, is it possible to add an alarm code? For example when temperature reaches at 39 degree the cell phone will give an alert

ruganattramn4 months ago

Hi, I can't open your videos. Could you please give me another link for videos? ( "Unable to resolve the server's DNS address" writing on the video)

adster6664 months ago

Hi I got it working perfectly when Arduino is hooked up via USB lead to the computer but when I connect the 9V battery pack it doesnt seem to power the module. Why is that and how can I untether my arduino/HC-06 combo from my computer, please?

Mr Arduino4 months ago

Can you use the above steps to turn the voltage current from the power source off?

mikeyaworski4 months ago

Can you please send me links to where I can order your btm222 module and ds18b20 sensor?

alacosta5 months 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



you are using the AI2 and this project was built under AI Classic....

so...either you switch back to AI Classic ..or the code under AI2

kodagames5 months 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!

Nilanj5 months ago

thanks for this

its not working on my HC-6

ted is not turning on or off.

ivver5 months 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

titi316 months 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..

OlawaleJegede6 months ago

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.

nero7777 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)  nero7776 months 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

OlawaleJegede6 months ago

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.

Nirav0086 months ago

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

calou16 months 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?

takkan7 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

jblakes348 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)  jblakes348 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

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

use ethernet shield

bjamose bjamose11 months ago
please help me
kerimil (author)  bjamose11 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_12348 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_12348 months ago

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

sam_1234 kerimil8 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

villadsen11 year 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)  glennballen8 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

1-40 of 125Next »