Introduction: How to Receive Arduino Sensor-Data on Your Android-Smartphone

In default the Arduino is not equipped with a display to visualize measuring-data, for example from your temperature or your pressure Sensor. If you want to get the data shown you need a PC, printing the data to the console or mounting a display directly to the Arduino. So there is no simple way to WIRELESSLY visualize measuring-data.

In this instructable i will show you, how to transfer measured Sensor-datain realtime from your Arduino-Mikrocontroller to your Android-Smartphone via Bluetooth.

Step 1: Preparing HC-05/HC-06 and Arduino

Requirements:

-Arduino

-Bluetooth-Module (HC-05, HC-06, ...)

-Android-Device

-App "Arduino Bluetooth Data"

The Bluetooth-Module HC-05/HC-06 is communicating with the Arduino via the UART-Interface. Every message the Arduino wants to send, is first given to the Bluetooth-Module, which sends the message wirelessly. To avoid problems with the UART, Arduino and Bluetooth-Module have to use the same baud-rate (in default 9600). It is possible to change the baud-rate and the password (and many other things) of the HC-05/HC-06, but this is not part of this instructable.

At first we have to do the wiring. The HC-05 has to be connected as descripted.

Wiring HC-05:

-GND of HC-05 to GND Arduino

-VCC of HC-05 to 3.3V Arduino

-TX HC-05 to Arduino Pin 10 (RX)

-RX HC-05 to Arduino Pin 11 (TX)

Important: HC-05 RX ist not connected to Arduino RX and vice versa.

Connect the Arduino to your PC and upload the following Code:


/*Developer: Frederik Hauke

Important Notices:

This Arduino-Code is written for Visualizating measurement data from a microcontroller via Bluetooth.

Before starting this application, the Bluetooth-Modul (HC-05) has to be coupled to the Smartphone.In the special case of the HC-05 the default PinCode for initiating the Coupling-Process is "1234".

Wiring: GND of HC-05 to GND Arduino, VCC of HC-05 to VCC Arduino, TX HC-05 to Arduino Pin 10 (RX) RX HC-05 to Arduino Pin 11 (TX) */

#include <SoftwareSerial.h>

SoftwareSerial BTserial(10, 11); // RX | TX

int sensorPin = A0;

int sensorValue = 0;

void setup() {

BTserial.begin(9600); }

void loop() {

sensorValue = analogRead(sensorPin);

//IMPORTANT: The complete String has to be of the Form: 1234,1234,1234,1234;

//(every Value has to be seperated through a comma (',') and the message has to

//end with a semikolon (';'))

BTserial.print("1234");

BTserial.print(",");

BTserial.print("1234.0");

BTserial.print(",");

BTserial.print("1234 hPa");

BTserial.print(",");

BTserial.print("500 ml/s");

BTserial.print(",");

BTserial.print(sensorValue);

BTserial.print(";");

//message to the receiving device

delay(20);

}

Step 2: Android App "Arduino Bluetooth Data"

The following app intents to process the incoming measuring-data and visualisates them:

https://play.google.com/store/apps/details?id=com....

Before using the app the Bluetooth-Module (HC-05/HC-06) has to be coupled to the Android in the system-preferences. In the special case of the HC-05 the default PinCode for initiating the Coupling-Process is "1234" or "0000".

If both devices are coupled, go to the app, pick the HC-05/HC-06 and click the red connect-button. "Arduino Bluetooth Data" should establish a serial connection.

In the Arduino-Code you determine on your own which values you want to send to the Android-Device. Just change these lines and fit in your own values:

BTserial.print(yourownValue);

Besides you can set a higher sampling-rate by lowering the delay: delay(yourownValue);

Feel free to do some experiments! Please, let me know, if something is not explained precisely enough!

Comments

author
malqutub (author)2017-08-02

hello, i have been trying to send data to my phone using an arduino pro min and the HC-06 module. The data is not showing up on the app/phone. The change I made is:

SoftwareSerial BTserial(1, 0); // RX | TX

Your help would be greatly appreciated.

author
r.xyreal (author)2017-06-14

Hello, is it possible for you to make the app an open source? or is it possible to do a tutorial for the android studio part? It's just that i have a final project that's due. I got all the sensors and the arduino codes working. It's the android studio part is what i dont get. I dont know how to make android studio receive data from the bluetooth

author
RoniA6 (author)2017-05-30

i was tried based on this instructions, but my HC05 didn't received any data. can you help me?

author
LookImDoinItMyself (author)2017-02-16

Hello, I was trying to use this as an example to work with a similar setup. The difference is that I have a Sensor Shield v5.0 plugged into the Arduino and the HC-06 plugged into the shield. The shield is marked with only TX RX - + do you know if there is a way that I can convert SoftwareSerial BTserial(10, 11); // RX | TX to work with the Shield.

author

As a follow up it looks like the RX, TX on the shield correspond to D0 and D1 on the Arduino so I'm currently trying them with the code to see if they work.

author

Following up again. I looked up more information on the code and the SoftwareSerial library. I understand how it works but I still cant seem to get a connection, even if I'm trying to connect via TeraTerm or if I'm using a 3rd party android app that I downloaded. Thinking the problem might be my HC-06 but I'll have to look into it further.

author

Finally got the connection to work. All good now.

author

Was there a problem with using HC-06 after all? I'm also thinking the HC-06 might be the problem

author

No, it doesn't appear to have been the HC-06 in my case. I have 2 others that I was using for testing though to be sure. Most recommendations seem to be to go with the HC-05 instead but I already had these leftover from some kits that I used. For me, the problem seemed to right itself after I started powering the Arduino from a battery before trying to connect to it remotely. Before that, I had it plugged into my computer like I would if I were connecting through TeraTerm but unplugging it and using a battery seemed to fix my connection issues.

author

As another follow up, I had trouble connecting again but this time it was the phone causing the problem. I simply shut down the phone and restarted it and that fixed the problem.

author
wadekar suvarna (author)2017-04-10

Hello Sir,

You have made Ardutooth App. I have dought in app making. I am making app for multiple sensor data display on app. I have used your app for trial. I have a made two screen in my app. In my app Bluetooth is connected on first screen and sensor data receive on second screen.I have trouble in receiving data on second screen. would you please explain me how can i receive data on second screen.

please reply as soon as possible.

waiting for your positive reply.

author
JigneshV3 (author)2017-04-02

what i have to do if i want only one sensor value to print ?

author
JHolland181 (author)2017-03-28

Awesome looking method! Would I be able to use this method and app on a larger scale? My goal is to collect different types of data from different sensors.

author
MartinL229 (author)2017-03-17

Hello Frederik,
Thank you for sharing. I was able to send text labels to the Android, but I'm trying to send data from a DHT11 sensor, so I combined both sketches but I'm not getting it. This is the sketch I'm Using:

#include <dht.h>
#include <SoftwareSerial.h>

SoftwareSerial BTserial(10, 11); // RX | TX

dht DHT;

#define DHT11_PIN 7

void setup() {

BTserial.begin(9600);

}

void loop()

{

int chk = DHT.read11(DHT11_PIN);
BTserial.print("Test");
BTserial.print(",");
BTserial.print("1234.0");
BTserial.print(",");
BTserial.print(DHT.temperature);
BTserial.print(",");
BTserial.print(DHT.humidity);
BTserial.print(",");
BTserial.print("sensorValue");
BTserial.print(";");delay(20);

}

I hope you can find the problem. Regards.

author
frederikhauke (author)MartinL2292017-03-18

Dear Martin,

are you sure you included the correct library?

author
MartinL229 (author)frederikhauke2017-03-19

Hello Frederik,

Thank you for replying. Yes, library is correct, I tested on the serial monitor. I reviewed the sketch and connections and found that I was using a wrong pin. I changed sensor pin and it worked! Thank you again.

author
Atul N Yadav made it! (author)2017-03-05

Thanks, these instructions helped me a lot. My version using Temp Sensot , LDR to sense environment and display values on smart phone. I am working on project to help rural school students to set up a mobile lab , so they could record various parameters like temp,humidity, light intensity etc via smart phone.

Set Up.jpg
author
YunaYu (author)2017-02-25

Hello, thank you for your project. It works really well. But for practical usage the app is too simple. At least it should be possible to rename the Sensors.

author
kcoronado1 (author)2017-02-13

When I press the red button the app does not do anything, it just displays pop-ups from time to time. Is the app not working? Please help

author
KrisK34 (author)2017-02-13

I got this working!

I can successfully send data from my Arduino to an Android phone (using HC-05), is there anyway (using any module) to send the same data from an Arduino to multiple Android phones?

author
SolahinS (author)2017-01-29

#include <SoftwareSerial.h>

SoftwareSerial BTserial(12, 13); //RX | TX

int pin_Out_S0 = 8;

int pin_Out_S1 = 9;

int pin_Out_S2 = 10;

int pin_Out_S3 = 11;

int pin_In_Mux1 = A0;

int Mux1_State[16] = {0};

void setup() {

pinMode(pin_Out_S0, OUTPUT);

pinMode(pin_Out_S1, OUTPUT);

pinMode(pin_Out_S2, OUTPUT);

pinMode(pin_Out_S3, OUTPUT);

//pinMode(pin_In_Mux1, INPUT);

Serial.begin(9600);

BTserial.begin(9600);

}

void loop() {

updateMux1();

for(int i = 0; i < 16; i ++) {

if(i == 15) {

Serial.println(Mux1_State[i]);

BTserial.write(Mux1_State[i]);

} else {

Serial.print(Mux1_State[i]);

BTserial.println(Mux1_State[i]);

BTserial.print(",");

Serial.print(",");

delay(500);

}

}

}

void updateMux1 () {

for (int i = 0; i < 16; i++){

digitalWrite(pin_Out_S0, HIGH && (i & B00000001));

digitalWrite(pin_Out_S1, HIGH && (i & B00000010));

digitalWrite(pin_Out_S2, HIGH && (i & B00000100));

digitalWrite(pin_Out_S3, HIGH && (i & B00001000));

Mux1_State[i] = analogRead(pin_In_Mux1);

}

}

this is not sending to bluetooth device

can you explain anyone

author
senthilsoorya (author)2017-01-28

its working fine...

author
waterguillaume (author)2017-01-25

Great job

Really nice app.

Is it possible to get the android code ?

I'd
like to have only the value of sensor (not the text like "sensor n°1")
and "always on top" function. The aim is to have the value of 3 sensors
overlay an another app (like navigation app). thank you

author
frans50 (author)2016-12-20

Great app, thans you. Could it be possible to make the sensor names user definable?

author
MikeS568 (author)2016-11-10

can you give the android code please ?

author
johnnyfrx made it! (author)2016-09-15

This was GREAT! I had created a LDR and wanted to get an accurate measurement of what to set the threshold to before I connected all to a relay. With your guide here I can sit at the other side of the room and watch the monitor via Bluetooth HC-06 instead. Thank you so much!

IMG_20160915_163147686_HDR.jpg
author
Kitu Singh (author)2016-04-15

As i am making my on app...i got success in sending data to arduino from phone but fail to receive data..

so please tell me the code for receiving data..

author
klamgade (author)Kitu Singh2016-07-08

Hi!! i have been trying to grab the sensor data outputting on my esp8266 on my IDE . And, use the sensor value on my android code to display on my own app.

Been trying lot but didn't could not figure out. If you could help with some ideas would be really appreciable. Thanks.

author
frederikhauke (author)Kitu Singh2016-04-16

The Code for receiving the Data is the heart of my work, it took me many, many hours of developing. I hope you unterstand it whould be uncomfortable for me, to simply give it to you.
Kind regarts

author
Kitu Singh (author)frederikhauke2016-04-16

Sure...no problem...

author
AndrewC230 (author)2016-05-21

Hello,

thank you very much for posting this and for your fine app "Arduino Bluetooth Data". Very functional and practical, easy to follow directions. LIke AllanM7, I also found that the rephrasing:

"#include <SoftwareSerial.h>

SoftwareSerial BTserial(10, 11); // RX | TX"

helped me be able to compile the code in Arduino.

best,

Andrew

author
frederikhauke (author)AndrewC2302016-06-05

Thanks for your positive feedback. I will edit your rephrasing to the instructable.

author
AllanM7 (author)2016-04-24

HI thanks for posting this I'm about to connect my electric car conversion to my phone using bluetooth, the possibilities are endless and this code is a great way of getting started, just thought it may be of use I couldn't upload the code until I changed the include statements to :

#include <SoftwareSerial.h>

SoftwareSerial BTserial(10, 11); // RX | TX

author
frederikhauke (author)AllanM72016-04-25

Your welcome ;)
Why don't you use the original declaration in my example? Or doesn't it work?
If SoftwareSerial does not work, send me a short message, i'll give you a solution.