I confess I have not used the AI2 serial component yet.
I have seen posts by other users on this board that have.
However, I have some questions for you that might help you:
Does the serial component have a Delimiter setting like the BlueTooth Client component, to help deliver only complete (println()) messages? If not, does your code have to look for \n in the incoming text?
Do you initialize before or after setting baud rate?
What is the difference between opening and initializing? Do you need to do both, and in any particular order?
I had a look at your .aia. I found 2 basic problems. You have to call open after initialize. You changed to SerialOTG in screen init, but your buttons still used the built in Serial. That's why you got the error "not initialized"
My advice to you if you want to learn more on using serial communication are:
Search the forum for “serial”.
If you want to use SerialOTG, read the documentation and take a close look at the example app:s
First: I can see you are using an old version with the suffix “serial” in the names. This has been removed since it’s redundant, and only makes the names longer. See the documentation for the extension.
With this extension, it should be possible to use serial, BT or TCP/IP in the same way, except for timing.
BytesReceived>0 only indicates you have received 1 or more bytes. In BT you most of the time receives a block of data, in this case a complete message (But not always depending on the BT module).
If you have fixed length messages, wait until you received all characters. If you use a delimiter LF, use a later version of SerialOTG that implements such a message handling.