Using serial with FTDI

...sounds very interesting, especially given the number of people that use App Inventor with microprocessors (and gadgets).

First version of an extension is available on github, rkl099/Appinventor-SerialOTG

EDIT: Here is the link: https://github.com/rkl099/AppInventor-SerialOTG

It is compatible with the built-in component Serial, extended with settings for parity, rts, dtr and refactored so it can be used with AI Companion. It has been tested with CdcAcm, PL2303, PL2303HX, FTDI, CP210x, CH341, CH341 (“fake”) and several android devices. I hope this will solve some problems discussed in the forum and make new applications possible.

Please return if you have any problems.

4 Likes

Hi again

Would it enable an App Inventor App to move files from a phone to a Windows PC via USB cable?

1 Like

that sounds great... could you please provide a link to your page there?
thank you

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Here is the link: https://github.com/rkl099/AppInventor-SerialOTG

No, the library Physicaloid supports transfer of files, but not to a PC:

  • supports uploading firmware protocols : STK500, STK500V2, Binary blob ESP8266 OTA

The upload function has not been included in extension.

This extension works with my Arduino UNO with CH340 + cable OTG.

Enable OTG in Android Settings.

It is a pity that there is still no extension to connect to any uart device via usb otg. Something similar to BT, but via USB. It would be great.

I am not sure what you are looking for. With this extension you can use an usb to serial adapter connected to your Android device that allows you to talk to any equipment with a serial port. It works with most common usb-serial adapters and chips. With this connection you can send characters (and string) data. You have to add the protocol. Arduino communication is just a special case, normally with a application specific protocol. I have used it for serial communication with a Pc to test the different adapters. It has been tested with CdcAcm, PL2303, PL2303HX, FTDI, CP210x, CH341, CH341 (“fake”) and several android devices.

2 Likes

Cool! Works perfectly with my adapter! Thanks for the extension. In my humble opinion, a damaged Serial extension from appinventor should be replaced with this extension. We have to apply for it somewhere ...

Glad to hear that! I have made a lot of testing myself, but I want to hear from more users. It can easily be included in AppInventor by replacing an external library (Physicaloid) and some other small changes to add functionality.
There are only some small changes in the library parts now used by AppInventor, so I know already that I don’t add problems and that it is much more useful than the current implementation. When I am sure it is working ok I will release the library as open source and suggest that it is included in AppInventor.

I noticed that the application sends data as text. Is it possible to send binary data somehow? As with BT text or data.

I am asking because the device with which I want to communicate receives data in HEX. For example FF 0E etc. I know that the USB terminal uses the library you were based on and there you can send and receive data in any form.

No problem with the library, but I depends on how ApInventor handles variable types. It is possible to extend read and write to handle int och char types. This is a question that I am interested in so I will have a look at the problem.

Even your example application sends 0 and 1, while your arduino program receives 30 and 31. It would be nice if there was a solution to it.

It is possible that app inventor would have to enter integer variables. Now I guess they're all char. A bit weird for a development environment.

For the built-in component, the WriteSerial method takes a string and expects that it's going to write to a device that understands strings. It would be straightforward enough to provide a second method that takes bytes instead of strings for the purposes of transmitting binary data over the serial port.

I understand that the author of the extension would have to do a little sign-to-number converter? I also read somewhere that appinventor plans to introduce variable declarations?

Would it be possible to make an additional block that would convert char to int? It would be enough to subtract 48 from char, I think.

Can't you do that with existing blocks ?