Hello to the community! I'm new here so I apologise I'm posting this in the wrong category. I'm having problems in communication between my arduino Uno and app. the app and arduino are not responding when commands are sent. I do not have much knowledge in either arduino or app development so I apologise if it is a simple issue. I have embedded both the arduino and App inventor code here. Thanks in advance!
Dear @Space,
what kind of Bluetooth shield have you connected to your UNO ?
A HC05 or HC06 or something else?
If you are using a HC05 or HC06, have you reversed the Tx and Rx pins between the UNO and the shield ?
Snce you say you are a "beginner", my hint is before trying to make working a complicated code, start with a simple one: just send a character from AI2 to your Arduino board, and show it on the Serial Monitor of the PC. As a second step, instruct your UNO to send back the same character to Ai2 and show this feedback into a label.
Only after you are done with such a basic code, you can build your final one.
The two files here below do the "simple job" (I've just posted them a couple of days ago for another user, don't care if the filename of AI2 .aia refers to an ESP32).
Please be aware that in my AI2 code the BT address is fixed into a text constant: you shall in place write the one of yours.
Best wishes
I looked at your blocks before looking at your sketch, so this post is only on problems with your blocks independent of whatever is going on in your sketch.
Both these Button Click events have the equivalent of wait loops in them, which won't work in AI2. The global variable being tested in the while loop will never get a chance to change value.
For details, see the articles on Event Based Programming at
Your Clock Timer should check for connectivity in an outer if/then/else test, to get a chance to announce disconnection before looking for incoming bytes.
I see you are using a ListView as an incoming data log.
Are you sure just creating an Element is enough to get that Element into the Elements list?
Also, that comparison to true is not documented, as far as I know.
Further down on the input comparison ladder, you switch from text comparison to numerical ascii code comparison. That won't work, since codes (82, 71) will be compared as two character texts against that single byte incoming text value.
So, before trying with a more complex code (both AI2 and Arduino) I suggest you to use my super-simple code to verify that the BT communication works.
Then check what @ABG has said, correct your code and go further.
PS provided that the hardware connection is correct (Tx-UNO to Rx-HC05 and Rx-UNO to Tx-HC05) and the baudrate as well (9600 ? )
I have found it simpler and more conservative to copy the ListView Elements into a variable, add the created Element to that list variable, then copy the whole list from the variable back into ListView.Elements
OK, since on my desk it works, this means that you have some differences in your hardware, or release of Android, that cause the malfunction. Any error message ?
You marked "solution" the previous post: is it really so ?
If yes, there is no need to go further.
Otherwise, since you say that it's connecting but not communicating, in my understanding this means that something is still not working.
Therefore, to verify which part is not working (AI2 or Arduino) I suggest to download fron google playstore the (free) app "Serial Bluetooth Terminal" and install it on your phone. With that app you should be in degree to echange messages with Arduino.
Are you using my Arduino code for HC05 ? Have you correctly reversed Tx and Rx pins ? Are you sure that the baudrate between UNO board and HC05 is the "good" one ? If it is not working with 9600, you can try 19200 or 38400.
Can you post a photo of your hardware ? (UNO+HC05+wiring)
please be aware that Tx and Rx are intended on UNO side, not on HC05, therefore the wiring you did, is a direct one, and not reversed.
Please cross the blue wire with the yellow one.
(though this is not explaining me how the comm's from AI2 to Arduino works and not the oppposite )
Sorry but I don't agree: the HW pins must be reversed otherwise you get a conflict between input and output and you can damage the ports.
Please leave the SW as original, and reverse the wires.The wires MUST be crossed.
Sure, if you send a character (i.e. 'A') from your app, you shall compare a character also in Arduino; something like:
at variables initializtaion:
char InputData = ' '; // please note that you cannot initialize an empty char but a space/blank
during receiving:
InputData = BTserial.read();
if (InputData == 'A') {do the job for 'A'};
else if (InputData == 'B') {do the job for 'B'};
and so on.