0

So i've been trying to connect my HC-05 BT module to PC. I'm sure i connected everything correct, i'm not new with arduino stuff. What i try to do now is i want to communicate with arduino using uart connection via BT. I have arduino leonardo, and here is my code:

void setup() 
{   
  Serial1.begin(9600); 
  pinMode(LED_BUILTIN, OUTPUT); 
} 
void loop() 
{ 
  if (Serial1.available()>0) {
  String ainfo;
    ainfo = Serial1.readStringUntil('\n'); 
  if (ainfo.equals("ON")) 
  { 
    digitalWrite(LED_BUILTIN, HIGH); 
    Serial1.println("LED On"); 
  } 
  else if (ainfo.equals("OFF")) 
  { 
    digitalWrite(LED_BUILTIN, LOW); 
    Serial1.println("LED Off"); 
  } 
  }
}

(i use Serial1, because Leonardo...) I connected HC-05 with PC, i mean i 'paired' it, because this is where the problem occurs.

My HC-05 is blinking, and when i open port 20, it stops blinking all the time, instead it blinks twice ever 2 seconds (blink twice, not two second blink). When i type anything to serial monitor, nothing happens. Arduino's RX diod doesn't even blink (i don't know if it should, but when i send data from another app through USB cable, it's blinking, so i think in this example it also should). I've downloaded an app on my phone, and tried to do send anything with a hope it will work, but it didn't, of course HC-05's diod behaved same as when i tried to send data from PC (blinks twice every two seconds). I hope you will find a mistake i make, or maybe the code is bad and that's the reason it's not doing anything.

Every Answer would be appreciated.

  • Are you following a [tutorial](https://howtomechatronics.com/tutorials/arduino/arduino-and-hc-05-bluetooth-module-tutorial/)?. Most Leonardo boards are 5V, have you used a level shifter? – Marcos G. Oct 24 '19 at 19:19
  • I have to say i didn't use any resistors, would it be a potential factor which could damage my board? I'll give this tutorial a try and will answer back. – Piotrek Wójtowicz Oct 24 '19 at 19:43
  • It still doesn't work, even with an app from the tutorial. – Piotrek Wójtowicz Oct 24 '19 at 20:01
  • Your problem seems to be between the Arduino and the HC-05 board. Can you explain how you wired those? Are you using pins 0 and 1 on the Leonardo? Have you installed the resistors? Have you checked if your board has a regulator (does it need 3.3 or 5 V for its supply?). In general you should have not damaged your board permanently but I cannot be sure – Marcos G. Oct 25 '19 at 04:21

0 Answers0