I am trying to connect to an HC-05 but it just does nothing when i try to connect

yeah i tried that, what is the baud rate anyway? i got this online because i don't know how to code cpp. but the HC-05 didn't connect at all, so i thought hmmmmmm... maybe the hc-05 baud rate is115200! tried that for gcc and,nothing.

Sorry, but I don't understand what you mean for " i don't know how to code cpp" : you don't need to code the cpp, you just have to enter the Arduino IDE and select my BT_send_Monitor.ino file, then modify this value:

then compile and download it by using this button:

This is all what you need to change the baudrate. Remember to unplug the wire from pin 0 of the UNO tied to the Tx of the HC05, otherwise the IDE cannot download the new executable on the board due to a conflict on the USB line.
Moreover I guess that the serial lik between the PC and the UNO board is correctly set,like here below (of course the serial port here depicted is only for example, it is mine, but you have to set yours).

But the baudrate is not important for the BT pairing between the HC05 and the Android device, so until the HC05 blinks rapidly, this means that it is not paired. Only after it is paired, the baudrate is used to exchange data between the UNO and the HC05.

i tried changing the buad rate but the hco5 stopped connecting, sorry about the last posts clarity. that is the number i changed, 115200 to 9600.

Your project is not "super difficult" but as it involves different things ( an arduino, an hc05, a phone, an app, a connection between arduino and hc05, a pairing between hc05 and phone... ), there is the chance that one ( ore more ) of these "things go wrong".
So it is important to verify each step ( and report accurately if and what does work/not work ).

  • first of all: never connect/disconnect wires when power is applied

  • the arduino sketch of @uskiara is a good starting point
    a) you have already changed the speed of btserial connection to 9600, good
    b) in the first lines the tx pin is defined as pin 10, connect this pin to the hc05 rx pin ( I already said adapt the 5V output voltage of the arduino to the 3.3V input voltage of the hc05, for example with the 2 resistors as shown by @uskiara )
    c) in the first lines the Rx pin is defined as pin 9, connect this pin to the hc05 tx pin
    d) connect the hc05 vcc pin to the 5V pin on arduino and connect the hc05 gnd to the gnd on arduino ( it should be already like this )
    e) this sketch uses a software serial to communicate with the hc05, so that pin 0 and 1 are used to program the board and for the debug via Serial.print, and you don't need to disconnect the hc05 any more
    f) optionally after the Serial.begin(9600); add a

    Serial.println("hello");

    ( a welcome message on the serial monitor, so that you know the program started )

  • power the boards, connect the arduino serial monitor and pair your phone to the hc05 ( do you see an hc05 in your phone bluetooth pairing option? )

  • do the hc05 leds show the module is paired?

  • open the bluetooth serial app @uskiara linked and try sending commands ( letters A, B, C, D... )

  • do you see any reply on the app? Is anything printed on the arduino serial monitor?

1 Like

ok, i have to connect/disconnect the rx wire, accordig to @uskiara to upload the code, and i don't want to do that because you said not to??? i don't know how to upload the code with the new info\warnings so i can't test and give feedback. if you could answer my questions i could test and see what's going on.

Dear @Hallston,
I understand that you're a bit confused, but what @davidefa is saying is to remove the wire from pin0 when the power supply to the Arduino board is not present. Then you have to power supply again the arduino board, so to download a new code. Once the code has been downloaded, you remove again the power supply to the Arduino board, you replug the wire to pin0 and at last you can switch on the Arduino board again.

In few words the Arduino board should be unpowered while you are unplugging/plugging the wire, Then you power-on it again.

Ok, one question a time ( it just takes a little longer ):

  1. did you already uploaded the arduino sketch @uskiara posted ( modifying the line BTSerial.begin(115200); with BTSerial.begin(9600); )?

ok, i don't know why but the HC-05 lost power, and the wires are firm in place. issue after issue after issue its goes.

  • HC-05 disconnects after screen switch

  • HC-05 constantly sends info, which is picked up and counted as a button press

  • not sending or recieving

  • lost power
    thank you all so much for all of your halp.

Let me try to clarify for myself:

ok, i don't know why but the HC-05 lost power, and the wires are firm in place. issue after issue after issue its goes.
=> so, now it works ? The App and the Arduino are exchanging messages ?

HC-05 disconnects after screen switch
=> Sure, the forum is plenty of threads where there is clearly stated that by switching between screens kills the Bluetooth communication. To avoid this, it is necessary to use "virtual screens"

HC-05 constantly sends info, which is picked up and counted as a button press
=> so the app counts how many times the button is pressed (Iinfo received on the BT) ?

not sending or recieving
=> again nothing works ?

lost power
(and I've lost my mind :grin:) => what this means ?

Please remember that the more detailed info/question you post, the more reliable answer you'll get.
Best wishes.

PS @davidefa have you understood something different ?

Re-reading the thread from beginning, the bt communication was already working on the beginning.
Now seems "something is broken" ( not sure of this ).
I'd check if:

  • arduino works ( can be programmed, the serial monitor works, the 5V are present... )?
  • the hc05 is powered ( 5v are present, any led on... )?
  • anything hot ( or smell )?

Check the battery?

:grimacing: oops. the list is just recounting the far to frequent issues that have already happened. sorry if you lost your mind. @davidefa, arduino is fine, leds are on, not noticably warm, the usual smell, like the HC-05 is not connected to the power. it is, though. i have a spare led, and i tested with it and the ground was unplugged from the breadboard entierly. i think i borrowed the ground's jumper wire for the resistor partition. also @ABG , the arduino is plugged in to my computer. we're back to the issue of the counter counting nonstop.

Good.
The fact the arduino transmits continuously ( even when the button is not pressed ) has "something to do with the button".

  • you should have already configured the button input pin as "input_pullup" and connected the "second pin" of the button to the gnd ( 0V ) of the arduino
  • disconnect this second pin of the button ( the transmission should stop )
  • reconnect this second pin of the button to gnd ( the transmission should restart )
  • if this is the case your button "is a short" ( if you used a 4 pin button, like the one in the schematic you posted, use 2 diagonal pins, to connect the button, not 2 adjacent pins )

P.S.
If you have a multimeter use it to verify that the button is shorted only when pressed

1 Like

its a code problem.it keeps countin even when i disconnect the ground. but i see nothing wrong with the code.
sorry i was gone so incredibly long.

void setup() {
  Serial.begin(9600); // Initialize hardware serial for Bluetooth communication
  pinMode(2, INPUT_PULLUP); // Set Pin 2 as input with internal pull-up resistor
}

void loop() {
  if (digitalRead(2) == LOW) { // Check if the button is pressed (LOW because of pull-up)
    Serial.println("B"); // Send the character 'B' (or any character) followed by a newline
    delay(200); // Debounce delay
  }
}

I'm on row 52 stitch 9

Yes, it is ok, maybe an hardware problem on pin 2?
Try using a different pin 3...

In addition to what @davidefa has already suggested (to change the pin), please try also a more drastic solution: remove completely the button: the transmission SHALL stop. (the capital letters aren't directed to you but to the Hardware... :rofl:)
If not, we will search somewhere else :thinking:.
But, I see that you trasmits on pins 0,1: this means that for now you are only transmitting to the Serial Monitor of Arduino, in other words only to the PC and not on the BT. Is my understanding correct ?

"I'm on row 52 stitch 9" of your white breadboard ? Sometimes the parasitic capacitance of the buried connection springs can introduce some unwanted behaviour (i.e. on frequency signals), but I don't think this is your case, for now.

ummm, my hardware does not listen to your authority (no offense). that settles it, code. its constanly sending data even whan the button is completly disconnected
from everything.
@davidefa said that the code is fine but maybe he missed something? i further tested and what seems to be going on is that the code sees a signal then takes off on its own. the pedal connected, then disconnect, it keeps transmitting. the pedal not connected from boot up, no counting. then i just put the switch in the pin itself. it works. ive been at this for six months now. thank you all for the abundant help you have provided.

Dear @Hallston, it is the first time that you write about a "pedal" : what's that ?
As far as I have read in your previous posts, there should be a pushbutton instead ...anyway, if the software is transmitting always, even if the pushbutton is not connected at all, this could be caused by a defective pin 2. Probably when you connected it, at the beginning, to the +5 Vdc while it was set as INPUT_PULLUP it has been broken (?).
Sorry that you've spent so many time (6 months !) in making a so simple application to work, but still now it's not pretty clear to me whether it is working fine or not... (..."then i just put the switch in the pin itself. it works"...)

yes i am using a pedal, but i used a pushbutton just to mean the same thing, thats all. and i just need to smooth out some minor, umm.... i can't think of the word but if i press the pedal in quick succession it won't count a few clicks so i'll smooth that out too. it works okay, just not the absolute best, thats all. and thank you all who helped me with this.

oh, i also haven't had tihs post for six months, i started six months ago. but i don't judge time very well so... it might have been about four months maybe? three? i don't know but it's fixed so i don't have to worry about it for a while. again, thank you to all who helped me in this project.

1 Like

To count every click of the pedal ( and count it only once ) an option is to use a proper button library in your arduino sketch.
The delay method you used is good for a test, but it may count the 'button press' 0,1 or more times ( depending on how long you press the pedal, but even on the synchronization between the pedal press and the arduino delay cycle )

1 Like