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

You would have to drop the incoming data into a variable if you don't want to immediately lose it after the contains block reports its results.

So if you wanted to save the incoming data for a log or for a total or for checking other input values, you would definitely need to capture it into a variable.

Variables are the dinnerware for data.
Don't visit the buffet without a plate.

1 Like

ok, so i don't want to save, so i don't need a variable? also it doesn't work, which is confusing. any help would be greatly appreiciated.

(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.

export_and_upload_aia

.

here:
gcc_copy_without_bluetooth(1).aia (613.1 KB)


Deal with your empty sockets, and apply Do It to all the dictionary lookup results in this event, to see why they fail comparisons.

oh, yeah i forgot about that,here is the new aia file, or the changes i made.
gcc_copy_without_bluetooth(2).aia (612.8 KB)

I see some "risky" blocks in your aia:


Here you don't evaluate the effectiveness of the BT connection: if the connection hasn't had success, you start the Clock1 anyway, and this can lead to an unexpected behaviour.You shall start the Clock1 only after a successful BT connection
Second: don't enable the clock to run in background, because it will run also when you've changed the screen, and this still will cause problems, because it operates on the bT, but the BT is ceased when the screens are switched. To avoid this, you shall stop the clock before leaving the Screen1, and reactivate it only when the BT comm's are restored. (Typically when the BT is needed it is better to use "virtual screens" instead. You can find how doing it, by searching the forum with the tag "virtual screens").

Here below is where you shall stop the clock before leaving screen1 :

And from that point onward the BT stops automatically its operations. And shall be reactivated when screen1 is restarted again.

About:

As I said, and as @ABG has confirmed, please store the incoming data into a variable (it costs nothing) and print the incoming data into a label, so to be able to see what is really entering into the app from the Ardiuino board. Once you've solved any doubt about the incoming message, you can just comment out (disable) that block, but leaving it there for any future needs. This also helps in understanding if the BT still works when switching between screens (remember to reactivate it whenever the screen1 returns to have focus).


All the best.

wait, what?! but

! (also, thats what google said so that may be wrong.)


this is what i did. it works right??? it doesn't work. not even with the HIGH setting

I'm a "simple man" ( and tend to have a "simple approach" to problems ).
Your "bluetooth receiving algorithm" is not functioning as expected?

  • save the received string in a variable and display it in a "debugLabel"
  • ( I'd also add the length of the string received, as you may find that arduino is sending not only 1 char )
  • I'd also verify that the arduino part is working as expected ( for example "serial printing" what transmitted via bluetooth ), and this should be the first thing to check

Is this last topic really of yours ?
I'm getting a bit lost !
It seems that these posts are getting back before my previous answers.

hmmmm... nope. i reply then you reply then i do then you do and so on. at least that i'm aware of.also @davidefa, made the text be put into a notifier, which should do the same thing, but in case it doesn't i put the text box in any way, but it still failand i did store it in a variable.

:rofl:
I see that we both are in a mess (more or less).
Let's start from scratch.
Fisrt of all we have to be sure that the BT transmission is working fine. When (and only after) we're done with that, we can go further.
To this purpose please find annexed an .aia that implements a transmission toward an Arduino system made by a UNO board together with an HC06. The annexed .ino is the correspondent Arduino code.
Please try them, and let us know.
BT_to_Arduino_1.aia (26.4 KB)

BT_Send_Monitor.ino (2.5 KB)

does it work on your end? it doesn't for me. did you code it for hc-05, or HC-06? and i did go into bt devices and connect manually, sent ab and c but nothing came back. i think it has a hardware issue, so i'll try to figure that out. that .aia file uncovered what i think (and hope to be) THE issue. thank you very much.

Yes sure it works for me otherwise I'd never had annexed it to the post :innocent:
HC05 or HC06 are irrelevant (unless your HC05 is set in Master mode, but unless you get a, "unusual" one, it shall be in Slave mode).
Can you please draw (also paper and pencil are enough :grin:) your HW setup ? I mean UNO+ HC05+ pushbutton. Another question is : do you use a battery or are you using a 5VDC power supply ?
Another hint is: to try to divide where is the trouble (50%-50%), you can use the SBT to send A, B and C to my Arduino code. In this case the SBT can tell you if the Arduino is connected properly, if neither with the SBT it works, most probably the issue is effectively there.

SBT = Serial Bluetooth Terminal, free on Playstore:


ohhhhhhh. right. :roll_eyes:
this is the basic setup.don't know whats going on because theres no loose conection.

I don't have the hc-05, but it should have a an internal 3.3V regulator, and the input voltage range should be 3.6V-6V ( double check this ).
From your schematic seems you are connecting it to the 3.3V supplied by the uno, connect it to the 5V.
Also note that the TX signal from the uno is a 5V signal, you should adapt it to the 3.3V level of the HC-05 ( for example with a resistor divider )
Last, in your sketch you have the button input configured as input_pullup, so you need to connect the button to gnd ( not to +5V ) to activate it

yeah i connected the hc-05 to 5V, but turned to 3.3V then back to 5V snd tested but also redid the button so that it closes to the groaud.

Dear @Hallston, from your schematic it is not cear how you connect the HC05 to the UNO, because the HC05 pins are not marked with numbers, anyway please take care of a couple of things:
Since you connect pins 0,1 of the UNO to the HC05, please be sure to cross the pins toward the HC05, that is: HC05 Tx pin to UNO Rx pin, and UNO Tx pin to the HC05 Rx pin.
Typically (but it is not mandatory if you just want to do some tests), the RX pin of the HC05 has to be protected by means of a resistors partition, like the following drawing


As just said, if you don't have some resistors in your drawer, until you just want to do some test, the protection is not mandatory, but will become better to be used when you'll be done with tests and you'll make the final setup.
Please be also aware that pins 0,1 of the UNO are intended for the Serial Monitor, therefore everything you send to the Serial monitor is also sent to the BT: this means that if you want to monitor on the PC what is received from the BT, for example:
datain = BTserial.read(); //data read from the BT
Serial.Println(datain); // data echoed to the Serial monitor
this produces a sending back to the BT as well, thus creating a mess on the BT line and, at the end, foolishing the app !!!
For the time being this does not apply to your code, since you just want to send a character to the app when the button is pressed, but please bear it in mind for the future.
In adition to all of that, every time you want to download a new code on the UNO, you shall disconnect the pin0 of the UNO from the HC05, otherwise it creates a conflict with the USB input, and the UNO board programming cannot be executed (it fails).
Regarding the pushbutton connection, as @davidefa has told you, and as I've already said, with a picture, in my post #16/38, the button shall be connected to GND

yep google told me that.

good, wanted confirmation that that (is that even allowed in grammar?) is true. :roll_eyes: :roll_eyes: :roll_eyes:

ah, that... i did connect it to ground but forgot to show that in the drawing.

OK, :+1:, so let's suppose that the hw is correct, you have tried my aia and ino that I've posted in post #32 and they did not work, what kind of error was shown ?
Or simply you haven't had any message (i.e. an Android message like Error 504 or others ) and everything remained stuck until a popup raised saying "the app is blocked Continue/cancel " ?

Let's try now in another way: please load my .ino, but be careful to modify the baudrate of the HC05 in my code from 115200 to 9600 because my HC06 works at 115200 but, as far as I've seen in your .ino, your HC05 works at 9600.
Once loaded, please run the SBT on your Android device and verify if it connects the HC05, by seeing that the red LED of the HC05 remains steady ON or it blinks twice slowly (it depends on which HC05 series you have, the LED behaviour can vary, but until it flashes rapidly, this means that the BT connection has not been linked successfully).
If the SBT says that the BT connection has been linked successfully, you can send the characters 'A', 'B', and 'C' and see what happens.
Pleas try this way and let me know.