loading

If you are looking to connect a BLE (Bluetooth 4.0) module instead of Bluetooth 2.0 module, please see my new tutorial: How to control Arduino with HM-10 (CC2541) BLE module and a mobile app.

Technology is progressing at break-neck speed, everyone of us has smart phones now-a-days, there are cool apps which let us stay in contact with our friends and family, get latest weather information or stay-updated with latest news but what's next? All of these are old-school techs by now, what is the next use of this amazing processing speed and cutting-edge communication method we carry around with us all times? If I say you can control the lights of your home, know that if heating is on? or if your mobile phone automatically shuts off your air conditioner? Ring bells?

Of course, here on Instructables, we all know these uses and using this tutorial we will build a circuit and control it through the mobile app and we will do it very rapidly, let's say you will be able to control lights of your home in under 20-30 minutes? Uh-oh, not really the lights but for brevity's sake we will be controlling an LED for now and you can add all kinds of circuitry later!

Let's start, we will need:

  1. A cheap and commonly available Bluetooth module known as HC-05, you can buy it from ebay with "buy it now price" starting from $4.17
  2. An Arduino, for this tutorial I will be using Arduino Uno.
  3. A solder less breadboard, 220 ohm to 1K ohm resistor and a LED
  4. Evothings Studio to rapidly develop our app in JavaScript

Let's go forward to the next step and start building our circuit!

Step 1: Connecting HC-05 Bluetooth Module with Arduino

HC-05 is a serial port module which makes it very easy to use. If you see the pin configuration of HC-05, there are total 6 but we only need 4 middle ones for our set-up.

  1. Connect VCC with 3.3V of Arduino, please do not connect it with 5V as that can cook the module
  2. Connect GND with any GND of Arduino
  3. Connect Rx pin with Tx of Arduino
  4. Connect Tx pin with Rx of Arduino

Now power-up the Uno using USB cable, a red light LED on HC-05 will start blinking, means we are ready to go forward to the next step!

<p>Arduino code?</p>
<p>Am I correct in thinking you don't need to use the breadboard, but you can connect the chip straight to the arduino?</p>
<p>Hi,</p><p>I have a problem. The red letters are not the same of blue letters. Do you know how to fix this?</p><p>Thanks a lot</p>
<p>why is my serial moonitor not working</p>
<p>hi,</p><p>My module pin names are different what should I do?</p><p>It dosent have vcc and instead it has a +5v pin, and now I don't know whether to connect it to 5v or to 3.3v.</p><p>Thanks in </p>
<p>You have to connect it to 3.3v and the +5v is the same thing as VCC. </p>
<p>Plz help me </p><p>when i uplod it show me error </p>
<p>You must unplug the HC-05 or HC-06 while uploading. I don't know why, but that's the error.</p>
<p>why i can not download from github ?</p>
<p>Hello to everyone.I have make a bleutooth robot which i can control it via android(tablet) and i have a problem with the code.I want from the robot to stop when connection lost or bluetooth disconnected.Now when the connection lost the robot go ahead and falls on the objects.How to add this line on the code?Can you help me please?The STATE pin of HC-05 when is HIGH is connected and when is LOW is disconnected.I put this on my code but it doesn't stop.Thank you for your time</p><p><br>The bluetooth that i use is HC-05<br><br>My code:<br><br>#include &lt;Servo.h&gt;<br><br>Servo SERVO_1; // Initialize Servo1<br><br>// Motor Control Variables<br>int PWM1 = 9;<br>int ENABLE1 = 8;<br>int PWM2 = 5;<br>int ENABLE2 = 7;<br>int PWM3 = 3;<br>int ENABLE3 = 4;<br>int PWM4 = 6;<br>int ENABLE4 = 12;<br>int STATE=2;<br><br><br>void setup() {<br> SERVO_1.attach(10);<br> Serial.begin(9600);<br> pinMode(ENABLE1, OUTPUT); //&Delta;ή&lambda;&omega;&sigma;&eta; ό&lambda;&omega;&nu; &tau;&omega;&nu; &mu;&epsilon;&tau;&alpha;&beta;&lambda;&eta;&tau;ώ&nu; &omega;&sigmaf; έ&xi;&omicron;&delta;&omicron;&sigmaf;<br> pinMode(ENABLE2, OUTPUT); //&Delta;ή&lambda;&omega;&sigma;&eta; ό&lambda;&omega;&nu; &tau;&omega;&nu; &mu;&epsilon;&tau;&alpha;&beta;&lambda;&eta;&tau;ώ&nu; &omega;&sigmaf; έ&xi;&omicron;&delta;&omicron;&sigmaf;<br> pinMode(ENABLE3, OUTPUT); //&Delta;ή&lambda;&omega;&sigma;&eta; ό&lambda;&omega;&nu; &tau;&omega;&nu; &mu;&epsilon;&tau;&alpha;&beta;&lambda;&eta;&tau;ώ&nu; &omega;&sigmaf; έ&xi;&omicron;&delta;&omicron;&sigmaf;<br> pinMode(ENABLE4, OUTPUT); //&Delta;ή&lambda;&omega;&sigma;&eta; ό&lambda;&omega;&nu; &tau;&omega;&nu; &mu;&epsilon;&tau;&alpha;&beta;&lambda;&eta;&tau;ώ&nu; &omega;&sigmaf; έ&xi;&omicron;&delta;&omicron;&sigmaf;<br> pinMode(STATE, INPUT);<br>}<br><br>void loop() {<br><br> if(digitalRead(STATE)== HIGH)<br><br> // see if there's incoming serial data:<br> if (Serial.available() &gt; 0) {<br> // read the oldest byte in the serial buffer:<br> int incomingByte = Serial.read();<br> // action depending on the instruction<br> // as well as sending a confirmation back to the app<br> switch (incomingByte) {<br> case 'F':<br> moveForward();<br> Serial.println(&quot;Going forward&quot;);<br> break;<br> case 'L' : // Case 'L' is received,<br> SERVO_1.write (180); // &Sigma;&tau;&rho;ί&psi;&epsilon; &Alpha;&rho;&iota;&sigma;&tau;&epsilon;&rho;ά.<br> SERVO_1.attach(10);<br> break;<br> case 'N':<br> turnright();<br> Serial.println(&quot;Turning right&quot;);<br> break;<br> case 'M':<br> turnleft();<br> Serial.println(&quot;Turning left&quot;);<br> break;<br> case 'O' : // Case 'L' is received,<br> SERVO_1.write (0); // &Sigma;&tau;&rho;ί&psi;&epsilon; &Alpha;&rho;&iota;&sigma;&tau;&epsilon;&rho;ά.<br> SERVO_1.attach(10);<br> break;<br> case 'B':<br> moveBackward();<br> Serial.println(&quot;Going forward&quot;);<br> break;<br> case 'P':<br> SERVO_1.write(90); // &Sigma;&tau;&rho;ί&psi;&epsilon; &Alpha;&rho;&iota;&sigma;&tau;&epsilon;&rho;ά.<br> SERVO_1.attach(10);<br> break;<br> case 'S':<br> moveNone();<br> Serial.println(&quot;Stopping&quot;);<br> break;<br> default:<br> // if nothing matches, do nothing<br> break;<br> }<br> }<br>}<br><br>void moveForward() {<br> // turn the driving motor on to go forwards at set speed<br> digitalWrite(ENABLE1, HIGH);<br> digitalWrite(ENABLE2, HIGH);<br> digitalWrite(ENABLE3, HIGH);<br> digitalWrite(ENABLE4, HIGH);<br> analogWrite(PWM1, 255);<br> analogWrite(PWM2, 255);<br> analogWrite(PWM3, 255);<br> analogWrite(PWM4, 255);<br><br>}<br><br>void moveBackward() {<br> // turn the driving motor on to go backwards at set speed<br> digitalWrite(ENABLE1, LOW);<br> digitalWrite(ENABLE2, LOW);<br> digitalWrite(ENABLE3, LOW);<br> digitalWrite(ENABLE4, LOW);<br> analogWrite(PWM1, 255);<br> analogWrite(PWM2, 255);<br> analogWrite(PWM3, 255);<br> analogWrite(PWM4, 255);<br>}<br>void turnright() {<br> digitalWrite(ENABLE1, HIGH);<br> digitalWrite(ENABLE2, HIGH);<br> digitalWrite(ENABLE3, LOW);<br> digitalWrite(ENABLE4, LOW);<br> analogWrite(PWM1, 255);<br> analogWrite(PWM2, 255);<br> analogWrite(PWM3, 255);<br> analogWrite(PWM4, 255);<br>}<br><br>void turnleft() {<br> digitalWrite(ENABLE1, LOW);<br> digitalWrite(ENABLE2, LOW);<br> digitalWrite(ENABLE3, HIGH);<br> digitalWrite(ENABLE4, HIGH);<br> analogWrite(PWM1, 255);<br> analogWrite(PWM2, 255);<br> analogWrite(PWM3, 255);<br> analogWrite(PWM4, 255);<br>}<br>void moveNone() {<br> // turn the driving motor off<br> digitalWrite(ENABLE1, 0);<br> digitalWrite(ENABLE2, 0);<br> digitalWrite(ENABLE3, 0);<br> digitalWrite(ENABLE4, 0);<br> analogWrite(PWM1, 0);<br> analogWrite(PWM2, 0);<br> analogWrite(PWM3, 0);<br> analogWrite(PWM4, 0);<br> SERVO_1.detach();<br>}</p>
Pleas Send me a image of Robot
U can remove &quot;void moveNone().........&quot; and replace with &quot;if(digitalRead(STATE)== LOW)......&quot;
<p>If someone has a problem regarding uploading the sketch to arduino while the bluetooth-module is connected(it always happens, and one has to disconnect the module at the time of uploading),use software-serial to use the bluetooth module instead of Tx(D1) &amp; Rx(D0) pin of arduino. </p>
<p>hello sir, i have a problem, i did everything you mentioned above and the phone is connected to the hc 05 but nothing happens when i send A or B, it only works on the serial monitor when i send the letters to the arduino, the HC 05 is connected but nothing works, can you help me please?</p><p> thanks</p>
<p>I'm having trouble with the app, I have slightly modified it to be able to do this with multiple arduinos/multiple HC-06 and modules when I select a device to connect with, it keeps displaying 'Disconnected', up to 4 times in a row.</p><p>Normally this wouldn't be such a problem were it not for the fact i'm going to use it for home automation for someone with severe muscle atrophy.</p><p>Any suggestions on what the issue might be or even how to fix it?</p>
<p>The EGBT-045MS Bluetooth modules (the smaller daughter board) is a 3.3v device. The HC-05 break out board has a 3.3v regulator that allows an input voltage of 3.6v to 6v but the TX and RX pins are still 3.3v. This means you can use the 5V out from the Arduino to power the boards but you cannot connect the Arduino directly to the HC-05 RX pin.</p><p>For the HC-05 RX pin (data in) you need to convert the Arduino's 5V signal level to 3.3v. A simple way to do this is by using a voltage divider made from a couple of resistors. A 1K ohm resistor and a 2K ohm resistor will do the job nicely. In your diagram, you are showing the Arduino connected *directly* to the module. Bad idea. Connecting a 5V signal to a module expecting a 3.3V signal would be like connecting a 7.6V signal to your Arduino. Would you do that? No. You need to step-down the signal voltage going into the HC-05's RX pin.</p><p>As a quick guide to the voltage divider; 1K + 2K = 3K. 1K is a third of 3K so it reduces the voltage by a third. One third of 5V is 1.66 and 5-1.66 = 3.33 which is what we want. Putting the resistors the other way would reduce the voltage by 2 thirds.<br>For more information on voltage dividers have a look at the <a href="https://learn.sparkfun.com/tutorials/voltage-dividers" rel="nofollow">Sparkfun tutorial</a></p><p>Since the Arduino will accept 3.3 volts as HIGH you can connect the HC-05 TX pin (data out) directly to the Arduino RX pin (The 5V Arduino takes a voltage of 3V or more as HIGH).</p>
<p>Hi Everyone,</p><p>I'm having a problem loading the Arduino code on Arduino. It can build the code but when I try to load the program it takes ages to load it and it never finish. Does someone have the same problem?</p>
<p>Dear you must be using same Serial port for HC 05 and to communicate with Arduino IDE. Just remove Rx and Tx connection between HC-05 and Arduino then upload your code, InshaAllah it will work. After uploading is done then again connect Rx and Tx connection to Arduino.</p>
<p>Thank you, nice project to start using hc05</p>
<p>thank you ! :)</p>
<p>niceee . thank you man i actually made my first arduino project thanks to you ! :)</p>
Sir .... cud u send me d evothings program ? for d app ... @ peeyushkvasc@yahoo.com i wud be thankful to u .
<p>You can simply download the software from evothings.com</p>
Hy :)) thx for information, so I made a matrix led 8*24 <br>I need to send text by using bluetooth to the matrix led<br>:thx to give help (y)<br>elamraniamine9@gmail.com
Bt sir... it is saying that.. u olways need a wifi to work wid the comp... anyways..if i started doing the project with another software like ai2 will they have an option to save ur file as a .apk cud u tell d differnce ?
<p>It doesn't give an option to save your files in an apk, you develop in HTML and javascript, when you are done, you can just take all your HTML, JavaScript, CSS, image files and package them for Android/iOS using either PhoneGap Build or Cordova CLI. There is a tutorial about this on Evothing's website: https://evothings.com/finalizing-an-evothings-app-for-store-submission-phonegap-build/</p>
<p>I have tried using Bluetooth Terminal to connect HC-05 with my android phone ( LG G4). it connects,But the LED does not blink. Please help me out with this situation.</p>
Here in that app they use &quot;a&quot; as ON and &quot;b&quot; as OFF. So who knows in Bluetooth terminal they might be using 1 and 0 for on and off
<p>what is the output voltage</p><p>is it 5v ?</p><p>then how can i make it from the 5v to a power that works a 0.5 HP motor</p><p>help me pls</p>
<p>What is the solution if it says &quot;Unable to connect device.&quot;???</p>
<p>thanks</p>
<p>I Made it Easily</p>
<p>thanks</p>
<p>You need a voltage divider between the Rx ping of the bluetooth module &amp; the Tx pin of the arduino if you don't want to fry your hc-05 (like I did). The bluetooth module wants 3.3v and if u give it 5v, it will only be a matter of time until it fries (10 minutes for me).</p>
Stucked at last step, not showing any bluetooth device as shown in ur screen shots though it is easily getting Connected using bluetooth terminal app.. Plz help
<p>Im getting error while upload the codes. See error code below: </p><p><br>avrdude: stk500_recv(): programmer is not responding<br>avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00<br>avrdude: stk500_recv(): programmer is not responding<br>avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00<br>avrdude: stk500_recv(): programmer is not responding<br>avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00<br>avrdude: stk500_recv(): programmer is not responding<br>avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00<br>avrdude: stk500_recv(): programmer is not responding<br>avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00<br>avrdude: stk500_recv(): programmer is not responding<br>avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00<br>avrdude: stk500_recv(): programmer is not responding<br>avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00<br>avrdude: stk500_recv(): programmer is not responding<br>avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00<br>avrdude: stk500_recv(): programmer is not responding<br>avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00<br>avrdude: stk500_recv(): programmer is not responding<br>avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00</p><p>how to solve this error ??</p>
<p>you could try 2 things</p><p>1) remove the tx and rx pins and then try to upload and then connect the pins</p><p>2) toggle between the first two programmers in the tools menu option</p><p>this should generally do the trick</p>
<p>same problem for me ! how do you solve it ?? ://</p>
<p>My phone is connected to the Bluetooth module but when i use the BLuetoothTerminal while connected to the HC-05, i can't manage to turn on/off the LED. Any Ideas?</p>
<p>Managed to fix the problem. Had to update Arduino and IDE, after that everything worked fin. Awesome tutorial, thank you very much!</p>
i made it thnxxxx .
<p>It already done and work well, i buit this with phonegap buil and i had to make config.xml.<br>I see tut from this page : <a href="https://evothings.com/finalizing-an-evothings-app-for-store-submission-phonegap-build/" rel="nofollow">https://evothings.com/finalizing-an-evothings-app-...</a></p><p>and add this code : &lt;gap:plugin name=&quot;com.megster.cordova.bluetoothserial&quot; spec=&quot;0.3.3&quot; source=&quot;pgb&quot; /&gt; to config.xml and i have stand alone android app. Well</p>
<p>Thanks...it's working...I'm using level logic converter because I read that hc05 should be use 3v for its Rx pin..I use this wire schematic </p><p><a href="https://rydepier.files.wordpress.com/2014/12/img_1551.jpg?w=625" rel="nofollow">https://rydepier.files.wordpress.com/2014/12/img_1...</a></p>
<p>Step 6 confuses me a bit, or rather: a lot.<br>Do I understand I need to install 'Cordova'?<br>and then install the bluetooth pugin you link to?<br>Or do I have to install 'Evothing' that already has that bluetooth plugin installed?<br>Subsequently you give 8 lines of code.<br>is that all that is needed?<br>In that case, I do not understand yr reply to kvascian in which u say it needs to be in html and java.<br>I am really really confused<br></p>
<p>Evothings Client is based on Cordova and bluetoothserial is Cordova's plugin. Evothings has everything you need for this tutorial. Just follow from Step 1 to Step 5. In Step 5, you will be asked to download Evothings Studio and also example app code from my github repository. Just follow the instructions given in this step.</p><p>Once you have the app working, you can then read from Step 6 to Step 8 to develop further understanding of how example app code is working.</p><p>About the reply to <a href="http://www.instructables.com/member/kvascian" rel="nofollow">kvascian</a>, that part comes once you have completed your app and now want to publish the app to Android or iOS app stores.</p>
<p>thanks. Spend most of the night programming an android app connecting over Bluetoothsending commands as well as receiving data. Am happy with the results, just may need a bit of an artistic improvement</p>
<p>thanks. Spend most of the night programming an android app connecting over Bluetoothsending commands as well as receiving data. Am happy with the results, just may need a bit of an artistic improvement</p>
<p>but how to send data from one arduino connected with HC-05 to another arduino connected with HC-05. diagram given</p>
<p>but how to send data from one arduino connected with HC-05 to another arduino connected with HC-05.</p>
<p>Many thanks!!!! My HC-05 works for the first time with your post (Led ON_OFF via bluetooth terminal)!<br><br>Next step for me: Cordova and Evothings Studio.<br>Have a nice day!</p>

About This Instructable

197,765views

117favorites

License:

Bio: I am a digital nomad and I often find myself navigating myself the fields of IoT, IIoT, VR, Voice Activation, Web and Mobile Apps and ... More »
More by hammadtq:Using Smart Phone as Motion Sensor Alarm Developing Mobile App to Control Lights of Two Rooms Remote Controlled LED using Mobile Phone and Internet 
Add instructable to: