Arduino Button check in a MIT APP

Try with
Write
and
WriteLn

Hello,
Can you help me, because when i problay mde a app, than i cant conected the Serial, for the Phone or tablet. I have a Samsung Galaxy S51 and a Tab S6 Lite. All of this two devices has OTG, i tested. But when i tried conected the Serial than i become this Error message all of twoo Devises.

That seems to be a bug in the extension that is not adapted to Android 12.

Maybe the author of the extension will decide to fix it.

Search this community about the FLAG_IMMUTABLE FLAG_MUTABLE error

When before you send me your Comment, then i looked in other Topics, and there i saw, this is a relative great problem. But thanks the answer.

Hello,
i tried the Data send from arduino via Otg. i do not find all of the blocks, like in yours App-s.
My app worked right, via Bluetooth, but i have to use on Otg. The Arduino code stayed the same like the bluetooth version. Can you help me, that what is wrong?

From what I can see, you are expecting an answer immediately after you send the request.
Please take a look at my documentation SerialOTG_1.4.pdf and examples:

“Remember that serial line communication is just a stream of bytes. There is no packet handling.
Each byte takes some time to transfer on the line. So if you send a request, then you have to wait for
a while, before you get an answer.
You have to add some kind of message handling yourself by timing, message length, content etc.

WriteLn(), ReadLn() implements a kind of message handling. It uses new line character to end an
UTF-8 message. Use ASCII char set (7-bit) to avoid problems if you communicate with Arduino.”

Have you tested the new version adapted to Android12, see Using serial with FTDI - #102 by Jambo ?

1 Like

Yeah , i tested with Android 12 ( Galaxy Tab S6 Lite) and i can data send to the Arduino. ( Led, on-off) , The device/app do not freez by me and it dont give Warning message to me.

Thanks, then I know.
I think the easiest way to communicate if you are not familiar with serial communication is by using writeln, readln, You can look at my examples ArduinoTime.aia, Time.ino to see how it works.

813f35e56d7b004ad477539ecbe565857c532fe0_2_397x500

Your csv to list conversion is backwards unnecessary. Does ReadBytes return a list of Bytes?

Also, it is wise to check length of list before attempting to select list items.

1 Like

I did not write in my before answer. When am i tested your new Extension for the OTG, than i used only the nb190 bugfixed MIT App Inventor.
http://nb190a-bugfixes.ai2-ewpatton-temp.appspot.com
I hope, that i linked right the URL.

Hi,

I didn't give up on this thing. I made a version, found a good sub-base for the app. For some reason it randomly throws this message, but when I touch the tablet, it disappears and then appears again.

Arduino Code:

int value_pot0;
int value_pot1;
String value;

void setup() {
Serial.begin(9600);
}

void loop() {
value_pot0 = analogRead(A0);
value_pot1 = analogRead(A1);
value = (String) value_pot0 + "," + (String) value_pot1;
Serial.println(value);
delay(200); // It should be slower than the Clock Interval.
}


Cannot see a csv Block in your code?

Sorry i don't understand, so the App do not see the csv Block, or what?

Not sure you can stream the data (ReadLn) directly into a 'list from csv row' block. It looks like the data may include something, like a newline or carriage return character, that means it is not going to convert into a list as it is not a perfect csv row.

Try streaming to a Label to see what you actually receive.

I looked in the serial monitor, and i think this is good. So i dont know what is the Problem.

Could be occasional data corruption between the board and the Android Device - or perhaps it is arriving too fast.......

Actually, stream it into a TextBox so it can be copy-pasted if required.

Looking at your monitor results, there is a newline after every value pair? If the data is streamed too quickly, the App is receiving:

506,520 newline 506,520

......which is not a legitimate CSV row

stream 506, 520, 506, 520 (etc) with a newline at the end is what you want to make the Block work, but if you need those pairs to be separated, send them as text like this:

506,520|506,520, etc ending with a newline. Stream goes into a var and the you can use the text split block @ '|' to separate the pairs into a List.

Huh, that was to many information me. My brain have to understand this.

Maybe you have not had enough coffee :joy: