loading

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!

<p>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</p>
<p>i was tried based on this instructions, but my HC05 didn't received any data. can you help me?</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>Finally got the connection to work. All good now.</p>
<p>Was there a problem with using HC-06 after all? I'm also thinking the HC-06 might be the problem</p>
<p>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. </p>
<p>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.</p>
<p>Hello Sir,</p><p>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. </p><p>please reply as soon as possible.</p><p>waiting for your positive reply.</p>
<p>what i have to do if i want only one sensor value to print ?</p>
<p>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. </p>
<p>Hello Frederik,<br>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:</p><p>#include &lt;dht.h&gt;<br>#include &lt;SoftwareSerial.h&gt;</p><p>SoftwareSerial BTserial(10, 11); // RX | TX</p><p>dht DHT;</p><p>#define DHT11_PIN 7</p><p>void setup() {</p><p>BTserial.begin(9600);</p><p>}</p><p>void loop()</p><p>{</p><p>int chk = DHT.read11(DHT11_PIN);<br>BTserial.print(&quot;Test&quot;);<br>BTserial.print(&quot;,&quot;);<br>BTserial.print(&quot;1234.0&quot;);<br>BTserial.print(&quot;,&quot;);<br>BTserial.print(DHT.temperature);<br>BTserial.print(&quot;,&quot;);<br>BTserial.print(DHT.humidity);<br>BTserial.print(&quot;,&quot;);<br>BTserial.print(&quot;sensorValue&quot;);<br>BTserial.print(&quot;;&quot;);delay(20);</p><p>}</p><p>I hope you can find the problem. Regards.</p>
<p>Dear Martin, </p><p>are you sure you included the correct library?</p>
<p>Hello Frederik,</p><p>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.</p>
<p>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.</p>
<p>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. </p>
<p>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</p>
<p>I got this working!</p><p>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?</p>
<p>#include &lt;SoftwareSerial.h&gt;</p><p>SoftwareSerial BTserial(12, 13); //RX | TX</p><p>int pin_Out_S0 = 8;</p><p>int pin_Out_S1 = 9;</p><p>int pin_Out_S2 = 10;</p><p>int pin_Out_S3 = 11;</p><p>int pin_In_Mux1 = A0;</p><p>int Mux1_State[16] = {0};</p><p>void setup() {</p><p>pinMode(pin_Out_S0, OUTPUT);</p><p>pinMode(pin_Out_S1, OUTPUT);</p><p>pinMode(pin_Out_S2, OUTPUT);</p><p>pinMode(pin_Out_S3, OUTPUT);</p><p>//pinMode(pin_In_Mux1, INPUT);</p><p>Serial.begin(9600);</p><p>BTserial.begin(9600);</p><p>}</p><p>void loop() {</p><p>updateMux1();</p><p>for(int i = 0; i &lt; 16; i ++) {</p><p>if(i == 15) {</p><p>Serial.println(Mux1_State[i]);</p><p>BTserial.write(Mux1_State[i]);</p><p>} else {</p><p>Serial.print(Mux1_State[i]);</p><p>BTserial.println(Mux1_State[i]);</p><p>BTserial.print(&quot;,&quot;);</p><p>Serial.print(&quot;,&quot;);</p><p>delay(500);</p><p>}</p><p>}</p><p>}</p><p>void updateMux1 () {</p><p>for (int i = 0; i &lt; 16; i++){</p><p>digitalWrite(pin_Out_S0, HIGH &amp;&amp; (i &amp; B00000001));</p><p>digitalWrite(pin_Out_S1, HIGH &amp;&amp; (i &amp; B00000010));</p><p>digitalWrite(pin_Out_S2, HIGH &amp;&amp; (i &amp; B00000100));</p><p>digitalWrite(pin_Out_S3, HIGH &amp;&amp; (i &amp; B00001000));</p><p>Mux1_State[i] = analogRead(pin_In_Mux1);</p><p>}</p><p>}</p><p>this is not sending to bluetooth device </p><p>can you explain anyone</p>
<p>its working fine...</p>
<p>Great job<br></p><p>Really nice app.</p><p>Is it possible to get the android code ?</p><p>I'd<br> like to have only the value of sensor (not the text like &quot;sensor n&deg;1&quot;) <br>and &quot;always on top&quot; function. The aim is to have the value of 3 sensors <br>overlay an another app (like navigation app). thank you</p>
<p>Great app, thans you. Could it be possible to make the sensor names user definable? </p>
<p>can you give the android code please ?</p>
<p>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!</p>
<p>As i am making my on app...i got success in sending data to arduino from phone but fail to receive data..</p><p>so please tell me the code for receiving data..</p>
<p>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. </p><p>Been trying lot but didn't could not figure out. If you could help with some ideas would be really appreciable. Thanks. </p>
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. <br>Kind regarts
Sure...no problem...<br>
<p>Hello,</p><p>thank you very much for posting this and for your fine app &quot;Arduino Bluetooth Data&quot;. Very functional and practical, easy to follow directions. LIke AllanM7, I also found that the rephrasing:</p><p>&quot;#include &lt;SoftwareSerial.h&gt;</p><p>SoftwareSerial BTserial(10, 11); // RX | TX&quot;</p><p>helped me be able to compile the code in Arduino.</p><p>best,</p><p>Andrew</p>
<p>Thanks for your positive feedback. I will edit your rephrasing to the instructable.</p>
<p>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 :</p><p>#include &lt;SoftwareSerial.h&gt;</p><p>SoftwareSerial BTserial(10, 11); // RX | TX</p>
Your welcome ;)<br>Why don't you use the original declaration in my example? Or doesn't it work?<br>If SoftwareSerial does not work, send me a short message, i'll give you a solution.

About This Instructable

32,819views

47favorites

License:

More by frederikhauke:How to Receive Arduino Sensor-Data on your Android-Smartphone 
Add instructable to: