Instructables

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
BTserialModule.JPG
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 133Next »
jkurarin2 months ago

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

Hi jkurarin

I hope this helps.

Blocks.jpg
JohnN310 days ago

kerimil, Thank you for sharing your experiences and knowledge. After retiring from a 30 year career in electronics the arduino platform has excited me again. I've build many discrete circuits, but building module to module is a whole new experience. I enjoyed this exercise however I am confused about a couple things (probably due to my inexperience). I've completed the led part and the on/off buttons work great. The voice command for on and off worked but blink didn't. I have just started playing with app inventor and wanted to load your build as you suggested in your narrative, to see what was happening but when I got to the page that was linked to I found a bunch of files and didn't know which one I was to download. If you could help me choose the correct one, you'd make an old man happy, then do I manually rebuild in the app inventor, or is there a way to upload it? Thanks again!

ed.darby JohnN39 hours ago

Hi JohnN3

I too had the same problem, I did some digging and it appears that the original app was built in App Inventor Version 1 which isn't compatible with the version 2 that is available now.

If you download the zip file listed in the article "bluetoothforarduino_app" from https://drive.google.com/folderview?id=0B_PfPoEotO... - you can go to - http://appinventor.mit.edu/explore/classic.html and import the zip file into "Classic" app inventor by going to "My Projects" then "More Actions" then "upload source" - The source being the zip file you d/lded above

Hope this helps :)

Ed

Hi I'm trying to do something similar but in my project I have to monitor 4 temperature sensors and turn ON/OFF 4 LEDs. How could I do this? Would it overload the serial communication between the arduino and the android? Please help me I just can't find an answer :(

First off all I would like to say that this is a great instructable, congratulations. I would like to ask you if it is possible to bypass the bluetooth module and connect the android phone directly via usb with the arduino. What I would like to do is to use the android phone as a shield for the arduino in order to use gps, wifi, and 3G sensors of my phone.I would like to be able to connect arduino to the internet throught the android phones wifi or 3g and control the arduino through internet

Bhanu Kishan made it!12 days ago

I used a BC 417 Bluetooth module. It worked when the baudrate is set 9600. Also leave the Rx (pin 0) unconnected while uploading the sketch to Arduino UNO. Thanks for this DIY. Good learning exercise.

DSC_7076.jpgDSC_7078.jpg
TimothyB224 days ago

can you control a relay insted of a led?

assyty1 month ago

Hello ... i've tried the receiving data,, at the first that file .apk can connect with bluetooth module ,, but why cant the data appeared yet?
i spent days to solved this problem :(

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.

agangwani2 months 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 :-)

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

ovi08193 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

amyymoo3 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 :)

drmpf4 months ago

If you don't want to do any Android programming, check out pfoDesigner http://www.forward.com.au/pfod/pfodDesigner/index....

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.

finalDesignSmall.png
ruganattramn5 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

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

adster6665 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 Arduino5 months ago

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

mikeyaworski6 months ago

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

alacosta7 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

J

hi

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

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

kodagames6 months ago

Hello,

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!

Nilanj6 months ago

thanks for this

its not working on my HC-6

ted is not turning on or off.

ivver7 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

titi317 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..

OlawaleJegede7 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.

nero7778 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)  nero7777 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

OlawaleJegede7 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.

Nirav0088 months ago

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

calou18 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?

takkan8 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

jblakes349 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.

jb

kerimil (author)  jblakes349 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 ->

https://groups.google.com/forum/embed/?parenturl=http://appinventor.mit.edu/explore/forums.html&showsearch=true&fragments=true#!topic/appinventor/Z30eETu0B1s

bjamose1 year ago
i wont to do this project using the wifi
the change is just in the bluetooth module or i need other
things
choconog bjamose9 months ago

use ethernet shield

1-40 of 133Next »