Error 507 hc 05 bluetooth module continuation

Please upload your .aia and your .ino files and we will take a look. Search the forum for advice how to do this.

USKled_1 (1).aia (5.2 KB)
sketch_dec14a_zavrsni.ino (2.2 KB)

image

Try turning on the Disconnect on Error flag in the Bluetooth Client, and adding an Else clause to the Connected test in Clock1.Timer, to announce connection failure.

I did it, should that somehow affect the label text, since i stayed the same, nothing changes.

This version uses your existing code ...
(draggable blocks)



I added a procedure to avoid duplication of code.

understood, I modified it as you said.

I still can't understand why it actually does not modify the text when state of the pin is changed to 0. Everything is received correctly when I tried it with serial monitor and with SBT...

Dear @Bruno_Dragas,
by having a look to your Arduino code i see:
image
so, first of all you store the value read from input 8 in the int x, then you don't use x but you continue to read input 8. Therefore or you use x or you trhow it away.
Then, in one of your previous messages you say that the 1 is received correctly by the app, while the 0, not.
Are you sure that your Arduino sends really the character '0'? For example if you swap the transmission like the following:
image
what happens at AI2 side: are you receiving '0'?
Or once more: if you transmit irrespectively to input 8 like the following:
image
Please note that I avoid the use of the function delay() that could cause strange behaviours since it disables the CPU interrupts
.

I tried it with swapping the characters and it showed character 0 and "ON". Int x stayed there by accident since I first tried printing int x instead of digital state of the pin, my bad... should I try your code if everything works with swapped values but not when the state should change?

Dear Bruno,
I try to repeat what you have said, to verify is I have correctly understood:
by swapping the sending, that is by sending '0' instead of '1' you see '0' in the app.
Is this correct ? If yes this means that your input(8) never changes or, at least it is read always at HIGH. What type of button do you have connected to input(8): a momentary pushbutton or a switch ?
In your code you have a delay(100) milliseconds. if you have a momentary pushbutton probably you never see a '0' because the probabbility to read the HIGH state is prevailing on the probability to read LOW.
Can you describe, with a schematic, what is your Arduino hardware ? And post an image too.
Cheers.

Hi, I am currently at school but I connected the microswitch by using pull up resistor. I tried it with SBT and state(0 and 1) changes as I change the microswitch state and I tried it with serial monitor without bluetooth and all worked fine

Ok, I know that being you at school you cannot do anything. :smirk:

Anyway, the schematic that you sent me is just a "theoretical one", not yours, indeed.
If you connect the input 8 to a pushbutton that closes to GND, you'd better set the input 8 as: pinMode(8, INPUT_PULLUP);
so you don't need to put an external pullup resistor and you can just close the pin to GND with a pushbutton. And when the pushbutton is not closed to GND, the input does not remain "floating" but it's tied to Vcc (5vdc hopefully, otherwise you have burnt the input) via the internal pullup resistor.

More: sure, I remember that with the SBT you say that it works but, if by swapping the '1' with the '0' you can read the '0', this means that the app is capable to receive the '0' when it is sent.

Once more I have rewritten the Arduino code, by cleaning it and by making a (substantial) difference: the transmission to the app (via BT) is made ONLY when a change in the input(8) is done, otherwise it does not transmit anything. By doing that, you have two side effects: first, the BT comm's is not overloaded every 100 ms, second,the delay(100) is not longer necessary.
sketch_dec14a_zavrsni.ino (4.0 KB)
After school (now you have to watch out for the professor !) try it without changing anything, and let me lknow.

For some reason I was unable to use pull up resistor via arduino so I decided to do it physicaly... thanks for your response. I will share my results when I get home

Hi, I tried it and I must say I am impressed, it works, the thing I am curious about is whether the decisive arduino code change was with variaables: newInput, oldInput and toBeTx, since I believe the motor thing you only modified to be more "more transparent"?

First of all, I'm really glad it works !
No, the difference isn't in the use of variables, nor in the "cleanliness" of the code.
The "big" difference is, as I already said, that the transmission to the app is done only when the input is changed and not every 100 ms. To do this I make a comparison between the current input reading (NewInput) and the old one. Only if they are different the transmisson is done.
Let me ask you the last question (though I have already asked) : do you use a momentary pushbutton or a switch with two stable ON/OFF positions ?
Could you please post the drawing of "truly your" hardware ?
(Ok I agree the questions are two.... :rofl: :rofl: :rofl:)

maybe I expressed myself wrong, by saying "use of those mentioned variables" I thought that using them prevents the overload by sending loads of data in the short period. I use momentary pushbutton. If you are looking for a picture of the project, here it is

Note that the led just acts there as a test, and those 3 resistors there are not used

Dear Bruno,
I believe that the answer to my question is here:
image
you are using a microswitch that is a "momentary pushbutton" (as you said). its status is normally open, this means that it is read by your Arduino always as HIGH.
Only if you you keep it pressed for a time sufficient to be acquired it is read as LOW.

You had 100 ms of delay, plus the transmission to the motor (25ms +25ms), plus the transmission to the Serial Monitor (@9600 = 15 ms), plus the transmission to the BT (@9600 = 3 ms); if in the meanwhile you had left the switch, it was read again as HIGH.

Anyway, form now on you have the road open in front of you !!!
Best wishes.

Many thanks sir, I really appreciate it.
Best regards,
Bruno

1 Like

My pleasure !!! :hugs: :hugs: :hugs:

1 Like

Hi, very rare question i would say, I literally made a new project with different name and with the same code with my desired design preferences and when I tried to run the app it failed at the first step(showing bt devices), why???