1

I have looked on google for an answer to my problems to no avail. The you tube video I am following is here: https://www.youtube.com/watch?v=f1v0IMegCvU So basically on my android, I can't see the HC-05 device show up and the module itself is flashing red unlike the video's flashing blue light. I have connected the circuit exactly like he has in the video with the 2 10K resisters. I am using the same app. What is wrong? Here is my code as I copied from the video.

void setup() 
{
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  Serial.println("Connection Successful!");
}
void loop() 
{
  if(Serial.available()>0){
    int data=Serial.read();
    switch(data){
      case 'a': LEDON();break;
      case 'b': LEDOFF();break;
      default : break;
    }
  }
  delay(50);
}
void LEDON(){
  Serial.println("Led On!");
  digitalWrite(13,HIGH);
}
void LEDOFF(){
  Serial.println("Led Off!");
  digitalWrite(13,LOW);
}

I also get the error avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00 when connected through usb. I do not get any errors when just flashing the arduino without any wires connected to the arduino. I know that the port is correct. Any ideas would be helpful. Thanks.

7
  • You write “I do not get any errors when just flashing the arduino without any wires connected to the arduino”. Q1: By 'flashing' do you mean sending a sketch to the Arduino? Q2: How does the sketch get to the Arduino if no wires are attached? Q3: What else is connected to the Arduino when the USB doesn't sync? Eg is the HC-05 connected? Q4: Re “I know that the port is correct”, what port do you mean? Q5: In the IDE, what board programmer or programming method do you have selected in the two cases? (Ie with or without USB connection) Jun 12, 2017 at 3:02
  • Answers: Q1=No, I mean just not having anything connected to the arduino other than the usb cable and selecting upload. Q2 answered by Q1. Q3=ground, 5v, tx,rx and those goes to the circuit on the breadboard just like in the video. Q4=port 1 and is genuine arduino it says. Q5=Not for sure what you meant by this question. I am using C programming language, is that what you meant? Confused here.
    – Bob G.
    Jun 12, 2017 at 3:57
  • Re Q1-2-3, looks like you mean uploading works ok when the only wire attached to Uno is the USB cable, but if app. circuit is attached it doesn't. Re Q4, what text appears when you hover the mouse cursor over the Tools, Port line? Re Q5, if you click Tools in the IDE, what shows up in "Programmer" field? Jun 12, 2017 at 5:09
  • It is Com 1. Then in the programming field it says, "Atmel STK500 development board."
    – Bob G.
    Jun 12, 2017 at 5:25
  • Can I just check you have the USB connected to the Arduino and the PC and you are using Serial to connect to the Bluetooth. If so that won't work. The code you have isn't reading from BT its reading the keyboard input of the PC. You need 'SoftwareSerial' to create a second serial port on an Uno, or use a Mega, to connect to the blue tooth, then you can put the HC-05 into pairing mode and all that stuff. Jun 12, 2017 at 12:00

2 Answers 2

2

There are several issues to consider:
• Program downloading
• HC-05 serial communication
• Bluetooth pairing

For the first issue: The serial-over-USB connection between the development computer and the Uno ties up the Uno's hardware serial RX and TX pins. There will be a conflict if the development computer transmits when the HC-05's TX is connected to the Uno's RX. This can be resolved by disconnecting the HC-05 TX when downloading a program.

For the second issue: The Uno schematic shows 1KΩ resistors between TX and RX on the ATmega328P and RX and TX on the USB chip (ie on an ATmega16U2, or a CH340, etc). If the HC-05's TX drive is strong enough, it will overcome the drive from the USB chip and work ok. Note, I would leave out the voltage divider (on the HC-05 RX line) that the video shows.

For the third issue: The HC-05 in the video mentioned in the question has a blue LED that blinks steadily when the HC-05 isn't paired, and blinks at a long interval when it is paired. Many HC-05's have red LEDs instead of blue; the LED color is not an issue. Some HC-05's don't blink at all when paired; that's not an issue either. What is an issue is that (according to description in question) your HC-05 keeps on blinking, so apparently isn't paired up.

Whether the HC-05 pairs with an Android app is more or less independent of whether you have the HC-05 connected to an Arduino; you should be able to pair your phone with the HC-05 when just Vcc and ground are connected to the HC-05. If you are having trouble with pairing, try another app; try powering the HC-05 down and up; and try a different HC-05. I mention trying another app because one serial-terminal app I installed on my Android phone needed the app or the HC-05 to be restarted to pair up after loss of pairing, and the serial-terminal app I replaced it with did not need those actions. Note, pairing takes a few steps on my phone: in Settings / Wireless, search for Bluetooth devices; select device; enter its passcode; run an app and tell the app which Bluetooth device to use.

5
  • I read through your answer and did what you asked me to or at least I think I did. So what I did is here: For the first issue I disconnected the HC-05 TX when downloading and it did it successfully unlike before. After downloading, I reconnected it since the arduino now has the code. Second issue: I left out the rx line resister and just put a wire in place of where the resistor was before for that line. Third issue: Noted. I tried different HC-05 and apps but after all these suggestions, it still has the same problem. More Ideas?
    – Bob G.
    Jun 13, 2017 at 0:15
  • By "same problem", you mean blinking LED and not pairing? That aspect doesn't depend on what the Arduino does -- it's up to the HC-05 and the phone. Do you have another phone to try? Did you enable BT discoverability of the phone? [I don't remember at the moment the ins and outs of pairing, ie what matters and what doesn't; you may need to do some web searching on that topic, for your model of phone.] Jun 13, 2017 at 1:43
  • I have the exact phone as in the video. I did research and nothing. And yes the same problem is blinking led and not pairing. I have BT enabled. I tried 2 different HC-05 with same results of blinking and not pairing. What is wrong? I did the same thing as in the video and it doesn't work? Just doesn't make any sense, it worked for him and I followed his exactly, so it should work.
    – Bob G.
    Jun 13, 2017 at 4:01
  • Does your phone discover the HC-05 like video showed? Did you send the 1234 or 0000 passcode? Those are prerequisites for pairing. Aside from that I don't have more ideas at the moment ... except I upvoted the question :) Jun 13, 2017 at 4:59
  • The phone doesn't see the hc-05.
    – Bob G.
    Jun 13, 2017 at 15:41
1

Try this code(it's simpler):

char data ;
void setup()
{
    Serial.begin(9600);                             
    pinMode(13, OUTPUT);  
}
void loop()
{
   if(Serial.available() > 0)      
   {
      data = Serial.read();        
      Serial.print("\n");        
      if(data == '1')     
      {         
         digitalWrite(13, HIGH);
         Serial.print("on");
      }
      else if(data == '0')         
      {
        digitalWrite(13, LOW);  
        Serial.print("off");
      }
   }
}

Upload this to your Arduino. Open your phone, go to bluetooth settings and connect to HC05 with password 1234. Download an app from here: https://github.com/Mayoogh/Arduino-Bluetooth-Basic Now your circuit should work. Arduino to HC05 connections: 5V -> 5V GND-> GND RX -> TX TX -> RX LED connection: connect LED to pin 13 and the GND pin beside it(it's fine if you don't use resistor).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.