Picture of Connect Arduino Uno to Android via Bluetooth

In this project a serial Bluetooth module is used to create a connection between Arduino Uno and an Android app that I created with MIT App Inventor.

Arduino listens for commands to light some LED's or show its status. In addition, a timer interrupt makes it check for temperature via a TMP36 sensor: if temperature is greater than a threshold a LED is lit; every n seconds (where n is a parameter set through the app) a status report is sent to the app. A simple command structure enables the app to send parameters and values to Arduino and the other way round.

There are many Bluetooth modules and even Arduino shields: my choice has fallen on JY-MCU that I bought from Hobby Components in the UK.

The JY-MCU is a class-2 Bluetooth module that acts like a serial port with no need of any software configuration on the Arduino. This module is available in several configurations, and this has been the first hurdle to overcome.

The one we need to make the connection between Arduino and the Android phone is a Slave Module. To make things very simple, there are two types of devices: Master and Slave; a Master can communicate with more than one Slave while a Slave can communicate with a single Master at a time, Master-Master and Slave-Slave communication is not allowed. Since the Bluetooth module in all smartphones is of Master type, the one we need for Arduino must be a Slave (this has nothing to do with client-server communication as we'll see later in the app description).

1-40 of 52Next »
CsillaS6 days ago

1. When I go out of range the connection is lost (there is no warning attempts to reconnect).
2. I move back into range .. must reconnect … the phone receive the status of the LED, but the new status not update in the app with the current state of the LED (attached printscreen).


this is my project android arduino bluetooth

The software can be used to control the electrical equipment in your phone to your home.

It can be used on your design and many designs can be cautious.

The software has been designed in Goods 10 interfaces required to control.

The serial send command can be used to control any amount of equipment.

You can get it with the file contains instructions on how to create the device.

The need for this basic Arduino code available.

We wish to provide the next version of the software can control from anywhere in the world.

But as for your ideas, suggestions please send it to us in the forum by software

for more information


ShashankR322 days ago

Great Instructable! One question though - If I were to make something similar, but just wanted the Arduino to send data to the App, data as in bits - 0 or 1, would Serial.println() or Serial.write() be appropriate?


AleA11 month ago

this is my circuit

AleA11 month ago

Hi,i woul like your help for a project that i have to tele-controll with android phone and hc-05 a 220v bulb.Actually i am using a 5v reley,a Photoresistor Sensor Module Light Detection Light for Arduino,android phone,arduino uno.Untill now this is the code i have used,is not complete.i am asking your help for this code because there are cases when i type to my android phone a 1 it dot give me always a 49 to serial monitor(arduino) or to the above condition i have specified that if the value i give is equal to 49 the bulb must stay on 2 seconds and off 8seconds,but it does the reverse,how can i solve this problem

if (ReadBT == 49)
Delay = 8000;
Delay = 2000;

digitalWrite(Relay, HIGH); // turn on relay
delay(10000-Delay); // time OFF
digitalWrite(Relay, LOW); // turn off relay
delay(Delay); // time ON


This is the code i have created until now

#include <SoftwareSerial.h>
int Relay = 7;
int BTtx = 10;
int BTrx = 11;
int ReadBT;
int Delay;

SoftwareSerial bluetooth(BTtx, BTrx); // TX | RX

void setup() {

// put your setup code here, to run once:

Serial.begin(9600); // opens serial port, sets data rate to 9600 bps

Serial.println("setup complete.");
pinMode(Relay, OUTPUT);

void loop() {
// if theres data from the bluetooth module
if (bluetooth.available()) {
ReadBT = (int)bluetooth.read();
//echo it to the serial monitor
//Serial.print("bt module said:");

//if theres data from the serial monitor
if (Serial.available()) {
ReadBT = (int)Serial.read();
//send it to the bluetooth module

if (ReadBT == 49)
Delay = 8000;
Delay = 2000;

digitalWrite(Relay, HIGH); // turn on relay
delay(10000-Delay); // time OFF
digitalWrite(Relay, LOW); // turn off relay
delay(Delay); // time ON


2.I have bought this light sensor for my project:http://www.ebay.com/itm/1PC-Photoresistor-Sensor-Module-Light-Detection-Light-for-Arduino/251673864995?_trksid=p2045573.c100033.m2042&_trkparms=aid%3D111001%26algo%3DREC.SEED%26ao%3D1%26asc%3D20131017132637%26meid%3D93d7e24c9d784838bf12ddf7c9ee88f1%26pid%3D100033%26rk%3D1%26rkt%3D4%26mehot%3Dpp%26sd%3D251673864995,can anywone help me with a code how to sens light intensity during day/night(considering even the condition that when it is bad/cloudy time i dont want my llamp to get turned on,i want the bulb to get turned on when the sensor sens the dark(for example 8pm) and to turn off the bulb when it is light(7 pm))

rehmp1 month ago

This is what I'm searching for. Thank you for this very informative post! Can you help me with my current project? My problem is I need to compare the Android phone's app (Speedometer) value to the Arduino programmed speed limit. So I need to connect my Android app to Arduino using bluetooth/serial connection. What is the code I need to put in my app? And what is the code I need to put in Arduino? Thanks. I'm a newbie.

SRS (1).jpg
hsnter1 month ago

Hi! I like your project,its really helpful for me. But i still need help about some details.I will use arduino nano and hc-05 bluetooth module on my own project. But how can i make the work mode as a slave? I know that i have to write a AT code. But how will I write this AT code on the program of Arduino? Thanks again..

LordPharaoh1 month ago

This is a really great tutorial, I was looking for this for a while - thanks! But before I make it, I have a quick question: do you know how much memory and processing this takes on the Arduino side of things? I was planning on using this with an unbuffered e-Ink display, which takes a bit over half (according to Adafruit, anyway) of the Arduino's power. I just want to be sure the Arduino can support both at the same time, and if not, buy another ATMega. Speaking of which, I'm planning on taking this out of Arduino into an ATMega 328 - there's nothing in your code which looks like it would require anything an ATMega can't do - am I correct?
Thanks again for the great tutorial!

pmosconi (author)  LordPharaoh1 month ago

Hi and thanks!

In reply to your questions: processing is negligible and memory is mostly related to the size of the strings you are using; in addition using program memory can further reduce the code footprint (if you are not familiar with it, this is an excellent tutorial: https://learn.adafruit.com/memories-of-an-arduino/...

When moving the code to other platforms, including ATMega, I strongly advise to get rid of the serialEvent() function and to move the code at the top of loop().

It goes like this:

if (Serial.available()) {

readBytes = Serial.readBytesUntil('\n', cmd, sizeof(cmd));

cmd[readBytes] = '\0';


This way it will work for any Serial port.


Also, thanks for the tutorial - it really helped.

Awesome! Thank you so much for your prompt reply!

RubenO32 months ago

What kind of range can you get with this?

pmosconi (author)  RubenO32 months ago
I've tested the BT module up to 10 mt, with a thin wall in between.
The theoretical range is much higher.
SadanandT3 months ago

This is another nice post on arduino and android interfacing, with trouble shooting techniques


win893 months ago

how to connect android to arduino use bluetooth automatically without fist pair before ?

pmosconi (author)  win893 months ago
You need to. code a native java android app for this: it's not possible with MIT App Inventor.
win893 months ago

awesome project

win893 months ago
dagopeter3 months ago

Hi pmosconi - this code is really awfully interesting for me. You have so good comments written into your sketch file for arduino. At least I had it put alltogether manually and understood a lot of your explanations of the code. But one thing I found nowhere on the web. What the hell means the "?" into your code:

else if (command.equals("YELLOW")) { // YELLOW=ON|OFF
value.equals("ON") ? digitalWrite(led1Pin, HIGH) : digitalWrite(led1Pin, LOW);

stringOK = true;

I found really no explanation whether in the Arduino - command or syntax - please give me chance - I do not understand it. By no means. Thanks for an answer.


pmosconi (author)  dagopeter3 months ago

Hi Peter, '?' is a standard C++ operator called "ternary operator" (http://www.cprogramming.com/reference/operators/te...

it's meaning is <condition> ? <execute when true> : <execute when false>;

For our purposes, it's equivalent to

if (<condition>) {

<execute when true>;


else {

<execute when false>;


If you need to know more about the difference between if-then-else and ?, see the language reference.

Hope this helps.

stercenio3 months ago

This is awesome tutorial. Thanks for sharing.

stercenio3 months ago

This is awesome tutorial. Thanks for sharing.

I am new to the hardware interfacing and stuffs .. Someoneplease guide on where to type the ARDUINO code .. and also .. incase i wanna PLOT a graph using the value that i get from the kit by using plotly but without an ethernet shield , what am i supposed to do ??? Kinda urgent

I am new to the hardware interfacing and stuffs .. Someoneplease guide on where to type the ARDUINO code .. and also .. incase i wanna PLOT a graph using the value that i get from the kit by using plotly but without an ethernet shield , what am i supposed to do ??? Kinda urgent

I am new to the hardware interfacing and stuffs .. Someoneplease guide on where to type the ARDUINO code .. and also .. incase i wanna PLOT a graph using the value that i get from the kit by using plotly but without an ethernet shield , what am i supposed to do ??? Kinda urgent

pmosconi (author) 6 months ago
Many thanks for your kindness!!
sammy0116 months ago

Hi Pmosconi,

This is exactly what I was looking for. Thanks for instructable.

I am having some challenges in displaying TEMP value on android phone. In my case it is printing full string. Will you be able to share your android java code? aia file above appears to be binary.

Appreciate your help. Thanks

pmosconi (author)  sammy0116 months ago
Hi sammy011, I developed the Android application with MIT App Inventor (http://appinventor.mit.edu/explore/) thus it is not native. From the link you'll find how to manage the aia file, which btw is a zip containing the whole App Inventor project.
In any case, what do you mean by printing full string? Maybe I can still help you.

sammy011 pmosconi6 months ago

Thanks Pmosconi for reply.

I resolved the issue with my setup today. The issue was I supposed to use lightweight sdk for nRF8001 BLE. I added it and app worked like charm.

Thanks for your response and offer to help. :)

+1 follow

numancelik347 months ago

Dear Pmosconi,
I use Arduino Uno for my
project, once I try to pair Bluetooth to PC, it's worked and then I try
to see my program is working. I use JY-MCU bluetooth module for this
project. The outcoming port is shown as COM 11, but when I want to try
to see in tools->Serial Port menu in the Arduino program, there is no
com port 11 at all there. I just can see Com port 9, but I need to see
COM 11 there to communicate with th PC. Could you please
help in this project, I have to solve this problem as soon as I can, so
could please get back to me ASAP, that would be very grateful. Many Thanks and Best Regards..
pmosconi (author)  numancelik347 months ago
Hi numancelik34,
have a look at this: http://ecno92.blogspot.it/2012/10/installing-and-testing-jy-mcu-bt-chip.html
It might help with the PC connection.

Still same issue, the outgoing COM port doesn't appear in tools--> Serial Port, thus I cannot communicate with the PC and send commands from the PC to the Arduino. I don't have any idea what the reason is. Do you have any other solutions to this problem?

pmosconi (author)  numancelik347 months ago
If the PC bt port is working with other devices, I have no idea otherwise the problem lies in the PC settings. Sorry, but I don't believe I can offer any additional help
pradipta037 months ago

Do you have any idea how can I do the same thing using the wifi module? have two wifi module in my house and want to use wifi rather than the bluetooth.Is it possible?


pmosconi (author)  pradipta037 months ago
Bluetooth in the end is like having a serial cable connecting the 2 devices; wifi is way more complicated: you'll use tcp over it and you'll need at least a web service on the arduino.
zefram-389 months ago

really nice job.

I've in mind project base on Arduino Uno + Sensor DHT11 ==> Moisture + temperature Sensor.

With DHT11 Sensor, we need to use DHT library.

hereby a sample squetch :

#include "DHT.h"

#define DHTPIN 8

#define DHTTYPE DHT11 //#define DHTTYPE DHT22 (pour un capteur DHT22)


float h = 0;

float t = 0;

void setup(){



Serial.print("Test Connexion");


void loop(){

h = dht.readHumidity();

t = dht.readTemperature();

if (isnan(t) || isnan(h))

Serial.println( "Lecture impossible !");


Serial.print("Humidite :");


Serial.print(" %\t");

Serial.print("Temperature :");


Serial.println(" *C");




I was wondering how it is possible (with few modifications) to adapt your code with this sensor instead of the TMP36?

there is a few difference with your squetch :

- Pin definition is Digital instead of Analogic

- Reading value (temp/moisture) is made inside the loop.

Thx 4 ur help.

sau.beo.73910 months ago

How can I convert the master-slave relationship (Android is slave and arduino is master), or anyway to send message or control android by arduino via bluetooth?

pmosconi (author)  sau.beo.73910 months ago

You can't change the master-slave BT relationship because the phone chip is of master type. Anyway, you'll probably looking at client-server communication: the client starts the exchange (the Android app in this example) while the server (Arduino) keeps listening for incoming client connections. You can certainly swap this logic by changing the logic of both applications.

In any case, also as it is now you can have Arduino send input to the Android app: this is happening with status messages that are displayed in the big text box in the lower half of the app screen.

SabriM10 months ago

Is android interface source code available? Open source?

pmosconi (author)  SabriM10 months ago
the code is available as an attachment to the Instructable (it is called BTArduinoConnection.aia) and it is open source.
1-40 of 52Next »