loading
This instructable shows you how to read sensor values from an Arduino with your Android device using a cheap bluetooth serial device you can order for under $10 on dealextreme or ebay.
This example uses Python as the scripting language for the Android scripting layer (SL4A) but you can choose from other languages like Perl, Lua, JavaScript etc. see: http://code.google.com/p/android-scripting/

Step 1: You need:

1. JY-MCU bluetooth wireless serial port module.
http://www.dealextreme.com/p/jy-mcu-arduino-bluetooth-wireless-serial-port-module-104299
or search for "bluetooth module" on ebay
I've bought mine for $8.20 on dealextreme.
2. An Android device with bluetooth.
3. An Arduino board.
4. Some sensor or potentiometer to read values from.

<p>find the code given in below link and troubleshooting techniques and circuit diagram</p><p>http://knowledge-cess.com/arduino-android-interfacing-example-code-and-troubleshooting/</p>
<p>nice!</p>
<p>What do you mean by &quot;sensor&quot; ?</p>
<p>can i use roboduino ATmega 328</p><p><a href="http://robokits.co.in/shop/index.php?main_page=product_info&cPath=72&products_id=34" rel="nofollow">http://robokits.co.in/shop/index.php?main_page=product_info&amp;cPath=72&amp;products_id=34</a></p>
<p>can i use roboduino ATmega 328</p><p><a href="http://robokits.co.in/shop/index.php?main_page=product_info&cPath=72&products_id=34" rel="nofollow">http://robokits.co.in/shop/index.php?main_page=product_info&amp;cPath=72&amp;products_id=34</a></p>
<p>can i use roboduino ATmega 328</p><p><a href="http://robokits.co.in/shop/index.php?main_page=product_info&cPath=72&products_id=34" rel="nofollow">http://robokits.co.in/shop/index.php?main_page=product_info&amp;cPath=72&amp;products_id=34</a></p>
<p>can i use roboduino ATmega 328</p><p><a href="http://robokits.co.in/shop/index.php?main_page=product_info&cPath=72&products_id=34" rel="nofollow">http://robokits.co.in/shop/index.php?main_page=product_info&amp;cPath=72&amp;products_id=34</a></p>
<p>can i use roboduino ATmega 328</p><p><a href="http://robokits.co.in/shop/index.php?main_page=product_info&cPath=72&products_id=34" rel="nofollow">http://robokits.co.in/shop/index.php?main_page=product_info&amp;cPath=72&amp;products_id=34</a></p>
<p>can i use roboduino ATmega 328</p><p><a href="http://robokits.co.in/shop/index.php?main_page=product_info&cPath=72&products_id=34" rel="nofollow">http://robokits.co.in/shop/index.php?main_page=product_info&amp;cPath=72&amp;products_id=34</a></p>
<p>can i use roboduino ATmega 328</p><p><a href="http://robokits.co.in/shop/index.php?main_page=product_info&cPath=72&products_id=34" rel="nofollow">http://robokits.co.in/shop/index.php?main_page=product_info&amp;cPath=72&amp;products_id=34</a></p>
<p>can i use roboduino ATmega 328</p><p><a href="http://robokits.co.in/shop/index.php?main_page=product_info&cPath=72&products_id=34" rel="nofollow">http://robokits.co.in/shop/index.php?main_page=product_info&amp;cPath=72&amp;products_id=34</a></p>
<p>can i use roboduino ATmega 328</p><p><a href="http://robokits.co.in/shop/index.php?main_page=product_info&cPath=72&products_id=34" rel="nofollow">http://robokits.co.in/shop/index.php?main_page=product_info&amp;cPath=72&amp;products_id=34</a></p>
<p>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...</p>
Hello Friend, I am doing a mechanical arm, and I wonder how I control the servos via Bluetooth? Has a model Tutorial? <br>thank you
can I test this application with hyper terminal in windows ? <br>i make a connection between mobile bluetooth and my labtop <br>and select the com port of the Bluetooth in hyper terminal <br> <br>but when i open the mobile application to send any thing from the terminal as a test before connecting the arduino <br>The application cannot start <br>it gives me w white screen with no thing else <br> <br>I installed the sl4a r4 and python interpreter <br> <br>but the problem still exists ? <br>
Hi metanurb, <br> <br>I have the exact bluetooth module that you have but I can't send anything to this module. Below is simple echo code that I use. Have I missed anything? <br> <br>Thank you. <br> <br>Arduino mega 2560 <br> <br>const int LED_PIN = 13; <br>boolean toggle = true; <br> <br>void setup() { <br> Serial1.begin(9600); <br>} <br> <br>void loop() { <br> if (Serial1.available()) { <br> Serial1.println(Serial1.read()); <br> digitalWrite(LED_PIN, toggle); <br> toggle = !toggle; <br> delay(1000); <br> } <br>}
With ArduinoDroid (https://play.google.com/store/apps/details?id=name.antonsmirnov.android.arduinodroid) you can develop for Arduino on Android: <br>
HI .. <br> please tell the program for arduino to transfer accelerometer sensor value serially using a bluetooth ttl interface
My bluetooth module is discovered by Nokia feature phone but Samsung Galaxy Ace can't find it. FYI, Ace is running on Android GingerBread 2.3.6. Is there any problem with class parameter of Bluetooth module? <br> <br>My module's documentation goes here :http://www.robokits.co.in/documentation/Bluetooth%20UART%20Module%201545.pdf <br> <br>I think this will be helpful to lot of other undocumented module owners cause I have similar module. <br> <br>Is there any idea how to make it discovered by Android?
I have done everything in the tutorial, but I don't get any values. The bluetooth does connect because the blinking led on the bluetooth module stops blinking and stays on. But I do not get any values. I have the HC-06 2.0 bought from ebay. Any ideas of what might be wrong? Am a total noob at this. Thanks anyway
I used the code below with the programs and scripts you provided. It should work right? What am I doing wrong? Please someone help, I really want it to work. I am using:<br> <strong><em>&quot;</em></strong><strong><em>HC-06 Bluetooth V2.0 RF Wireless Transceiver Module Interface RS232 TTL&quot;</em></strong><br> <br> <strong><em>This is my code:</em></strong><br> <br> #define trigPin 13<br> #define echoPin 12<br> const int LED1 = 8;<br> <br> int sensorValue = 0;<br> <br> boolean toggle = true;<br> <br> void setup() {<br> &nbsp; Serial.begin (9600);<br> &nbsp; pinMode(trigPin, OUTPUT);<br> &nbsp; pinMode(echoPin, INPUT);<br> &nbsp; pinMode(LED1, OUTPUT);<br> }<br> <br> void loop() {<br> &nbsp;<br> &nbsp; if (Serial.available()) {<br> &nbsp; Serial.read();<br> &nbsp; }<br> &nbsp;<br> &nbsp; long duration, distance;<br> &nbsp; digitalWrite(trigPin, LOW);&nbsp; // Added this line<br> &nbsp; delayMicroseconds(2); // Added this line<br> <br> &nbsp; digitalWrite(trigPin, HIGH);<br> //&nbsp; delayMicroseconds(1000); - Removed this line<br> &nbsp; delayMicroseconds(10); // Added this line<br> &nbsp; digitalWrite(trigPin, LOW);<br> &nbsp; duration = pulseIn(echoPin, HIGH);<br> &nbsp; distance = (duration/2) / 29.1;<br> &nbsp; if (distance &gt;= 200 || distance &lt;= 0){<br> &nbsp;&nbsp;&nbsp; Serial.println(&quot;Out of range&quot;);<br> &nbsp;&nbsp;&nbsp; digitalWrite(LED1, LOW);<br> &nbsp; }<br> &nbsp; else {<br> &nbsp;&nbsp;&nbsp; Serial.print(distance);<br> &nbsp;&nbsp;&nbsp; Serial.println(&quot; cm&quot;);<br> &nbsp;&nbsp;&nbsp; digitalWrite(LED1, HIGH);<br> &nbsp;&nbsp;&nbsp;<br> &nbsp;&nbsp;&nbsp; sensorValue = Serial.print(distance);;<br> &nbsp;&nbsp;&nbsp; digitalWrite(LED1, toggle); // toggle the LED<br> &nbsp;&nbsp;&nbsp; toggle = !toggle;<br> &nbsp; }<br> &nbsp; delay(500);<br> }
Great stuff! Thank you so much! :)
Hi! <br>Is there any way to just send serial command to arduino like the serial monitor in the IDE? <br>Anyway, Pretty neat instructable....
I am using Samsung galaxy note 2. when i run androino.py i get a black screen and then crashes,&quot;unfortunately, SL3A has stopped.&quot; any solution?
Nice instruct able. I do have one issue, when I run androino.py it doesn't open the html in a WebView, I see it in plain text :(. Any ideas?
Excellent, thanks for this - managed to tx/rx data dynamically between my website and my pad and the Arduino - fantastic - thanks again! <br> <br>One question, as my Python scripting is not that hot - if I wanted to connect multiple bluetooth modules e.g. 2+ and route them all through my pad to my website how would I poll each module? something like this?..... <br> <br>For x = 0 to (amount of bluetooth modules) <br> If BT(x) connected/success Then ..... <br> TX/RX <br> End If <br>Loop <br> <br>
Thank you for this. I have a problem, I loaded everything as per your instructions including the device I. When i load the androino.html it just opens the html file in text form. Is my android O.S. to old? Thanks <br>
hello i have been having trouble with youre code . every time i run the androino.py code i get this Message <br>[SyntaxError: can't assign to operator (androino2.py, line 13)] <br> <br>line 13 is the line where i am assigning the BT_DEVICE_ID. <br>
Thanks for such a straightforward tutorial - I feel like an idiot having issues, where everyone else seems to have succeeded! <br> <br>When I open SLA4, all I see is the html file, not the py file, which is defininately in the same directory as the html one... <br> <br>Any thoughts on where I've gone wrong? <br> <br>Thanks in advance :)
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! <br> <br>Great for making buttons to send what you want for your commands. message me if you want an example of what I did for my android controlled car. easier in my opinion than a keyboard with small letters and big fingers.
Thanks for the project. I found this after making a BT module work with a Picaxe14M2 and a little Android app called the Rocket Controller <br>from -- http://rocketbrandstudios.com/ -- This worked fine and returned <br>either an 8-bit or 10-bit value (depending on the call in the axe firmware) that <br>matched voltage on a pot (turn the pot, get a new value). <br> <br>So now I am trying to use your Python approach. I have the BT only connected as a transmitter from the Picaxe and it just loops and sends a value out. When I run the Python code I see the connection light work but nothing happens when I click &quot;get sensor data&quot;. I also tried the &quot;dump.py&quot; code. It also connects and gives back a couple of lines -- <br> <br>Result(id=2, result=u' .. very long what look like a MAC address ...', error=None) <br>Result(id=3, result=u'linvor', error=None) <br> <br>-- and then nothing else. From some looking around, it looks like 'linvor' may be the default name for the module. Any ideas? Is there someplace where I can find documentation on ... droid.bluetoothReadLine() ...? Thanks for any help. <br>
Posted too soon -- changed &quot;bluetoothReadLine()&quot; to &quot;bluetoothRead()&quot; and it works !! Also found -- API reference -- <br> <br>http://code.google.com/p/android-scripting/wiki/ApiReference <br> <br>
When I goto bluetooth settings it finds linvor and I can pair with 1234 but it says paired but not connected. When I run the script it says javo.io.exception service failed to start. then it goes to the html and when i hit get sensor data it says sensor value null <br> <br>any thoughts
that was it. works like a champ <br>Now I would like to reverse it and have the android phone send a signal to the arduino to turn a led on and off
did you change the line: <br>BT_DEVICE_ID = '00:11:11:18:62:60' <br>to the id of your module?
How do you find the address of your BT Module? Also, for some reason, I cannot detect my BT module (w/ my Android) when it is hooked up to my Arduino as described above. Do I need to change the settings to make it findable?
You see the address in the android system settings -&gt; bluetooth. <br>Did you pair the module with your android? <br> <br>
Is the address that goes into the .py file the bluetooth address of the Android or the BT address of the module? When my module is powered it is recognized w/ the device name &quot;OBDII&quot;, not linvor. I am able to pair with it using the pin 1234 but then when I run the .py file in sl4a and press the gear, nothing happens. <br> <br>If the address that goes into the .py file is from the BT module, I'm not sure how to find it. As far as I can tell, I cannot find it just by looking at the module in the list of devices shown on my phone. Could this be that I am using an older phone (Nexus One), or the 2.3.6 operating system? <br> <br>So you know, I ordered my piece from Ebay but it looks almost identical to the one shown above from dealextreme. It's my theory that the settings were changed by whoever the vendor was. The only physical difference I can see in the parts is that the gold strip that &quot;zig-zags&quot; at the top of my module has one less &quot;zig-zag&quot;. I don't know what it does though. See the image I attached of my own module.
The device id of your BT module goes into the .py file. You don't have to enter it at all, if the parameter is missing android shows you a dropdown menu where you can select the paired adapter: droid.bluetoothConnect('00001101-0000-1000-8000-00805F9B34FB')<br> For changing the module name, baud rate etc.: <a href="http://wiki.openpilot.org/display/Doc/Serial+Bluetooth+Telemetry" rel="nofollow">http://wiki.openpilot.org/display/Doc/Serial+Bluetooth+Telemetry</a><br>
I ordered from dealextreme, taking forever, 3 weeks and I had to email them twice about the status to get them to ship it. <br>Advice to anyone else in the USA, use a North American seller on eBay.
Yeah.. I'm too waiting for stuff that I ordered 3 weeks before :/ <br>And sometimes the orders get stuck in customs for over a week here in germany :( <br>
I ordered an Ethernet shield from DX almost 2 months to the day and have not seen it despite it being &quot;shipped&quot;. I'd recommend sending others to a more reputable site like Maplin (UK) or Sparkfun (US) before sending them to dealextreme. <br> <br>Thanks for the writeup - I'll be trying this soon. :-)
This is awesome! I just got mine up and working. There is one thing I wanted to point out for others trying to do this. <br>In the androino.py python script, the following line of code opens the webview. <br> <br>droid.webViewShow('file:///sdcard/sl4a/scripts/tulpe/androino.html') <br> <br>In my case I had to modify the code to exclude &quot;/tulpe&quot;. So it now reads <br> <br>droid.webViewShow('file:///sdcard/sl4a/scripts/androino.html') <br> <br>Without this change, I was getting a blank screen that did nothing because androino.py couldn't find the html file. <br> <br>Anyway, Thanks metanurb for this instructable! I can't wait to start making awesome bluetooth telemetry stuff!
Oops.. I've updated the code.. thanks! <br>
hi this is my first time hear and im soo excited! can i use a bluetooth dongle and wire the into my arduino? in other words is there much difference in a bluesmirf and a d link bluetooth dbt-120?
This looks really cool.<br><br>Question re the bluetooth: How does the JY-MCU compare to the BlueSmirf modules? It's a lot cheaper and so I was going to order one, but why is this one 8 bucks and the others are 40-60?<br><br>Also, what baud rates can you get through this module? If I had a python module talking to the bluetooth, how many commands could I issue per second?
I don't have a BlueSmirf so I can't compare them.<br> Baud rate goes up to 230400 and I have mine running reliable at 115200 (7m indoor).<br> More info about the baud rates can be found here: <a href="http://wiki.openpilot.org/display/Doc/Serial+Bluetooth+Telemetry" rel="nofollow">http://wiki.openpilot.org/display/Doc/Serial+Bluetooth+Telemetry</a><br> As for the rate: 115200 / (8+1) = 12800 byte / second (if I get this right).<br>

About This Instructable

316,119views

233favorites

License:

More by metanurb:Add a little two analog axis thumb joystick to your existing joystick.Androino! Control an Arduino from your Android device using a cheap bluetooth module.
Add instructable to: