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

Remove these adsRemove these ads by Signing Up

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) 2 months ago
Many thanks for your kindness!!
sammy0112 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)  sammy0112 months ago
Hi sammy011, I developed the Android application with MIT App Inventor ( 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 pmosconi2 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

numancelik342 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)  numancelik342 months ago
Hi numancelik34,
have a look at this:
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)  numancelik342 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
pradipta032 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)  pradipta032 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-384 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.7395 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.7395 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.

SabriM5 months ago

Is android interface source code available? Open source?

pmosconi (author)  SabriM5 months ago
the code is available as an attachment to the Instructable (it is called BTArduinoConnection.aia) and it is open source.
pmosconi (author)  pmosconi5 months ago
Don't drive the motor directly from the Arduino output, but use an external source. There are a lot of examples and explanations about this in various scenarios.
SabriM pmosconi5 months ago

Thank you I got that. Created in app inventor. I would like to ask something else. Can I use a more powerful DC motor for ardunio uno? whats the max voltage of uno? Thanks in advance.

1beertap8 months ago

I really like your code, but how can I change it to convert Celsius to Fahrenheit and display it?

pmosconi (author)  1beertap8 months ago

Sorry, for the delay. In this great Adafruit tutorial you can find all info you need:

1beertap 1beertap8 months ago

Nevermind, I took the output of the Celsius temperature, using a formula I converted it to Fahrenheit, and saved the data to another variable I created and then printed the new data. Thanks for sharing!!!

can i use

Freeduino USB with Atmega8

mcdrew2 made it!8 months ago

GREAT INSTRUCTABLE!!! This is the first time I have tried bluetooth so the detailed explanation was extremely helpful. Everything worked as described. I am planning to try and adapt this to a automatic door opener control as I am in a wheelchair.

First bluetoooth led.jpg
pmosconi (author)  mcdrew28 months ago

Many thanks :-) !! You might want also to check Bluetooth Low Energy (BLE, iBeacon, ...) technology to trigger proximity actions such as open a door when automatically when you're close by. The problem with it is that MIT App Inventor doesn't support it so you need to use "real" programming or prepackaged applications.

mcdrew2 pmosconi8 months ago

If I wanted to take out the interrupt feature so it only read the status when requested what specific code would I remove.

Thank you.

pmosconi (author)  mcdrew28 months ago

Hi, the interrupt routine is initialized between the instructions

cli(); // disable global interrupts


sei(); // enable global interrupts

at the end of setup() function, so just delete all lines from cli(); to sei(); included.

Also, you won't need any more the interrupt routine itself: delete the function ISR(TIMER1_COMPA_vect)

Hope this helps

mcdrew2 pmosconi8 months ago

Awesome! Thank you.