Android Question A simple text terminal for Arduino (CH340 chip) running on Android? How?


Hello everyone!
I'm trying to write a program for B4A (android 7..10) which should be a text terminal and a basic editor window for an Arduino nano program.
The Arduino nano has Tiny Basic installed which communicates with an external terminal or programming via plain text. It uses a serial virtual com port on the CH340 chip (Chinese driver).
This Arduino BASIC can receive a program or execute commands like a regular remote text server. Those. it accepts and transmits lines of text with an end (newline).
When I use a Windows computer and a usb connection, a virtual com port is created, the CH340 driver is loaded and everything works fine.
When I connect my ardruine with a basic interpreter to OTG Android, the android not sees the CH340 chip point blank.

I need to write a beautiful basic code editor for the interpreter running on the Arduino board, and also get beautiful text and digital results of the basic work from Arduino.

I can do everything beautifully and correctly, except for the implementation of a simple text communication channel with the 340 chip from Android

I've been studying forms for a week now and trying many examples!
I can't figure out how I can do such a simple thing, which is in all textbooks for communication between a 340 chip and another device (terminal).
Class Serial port
Method: Initialize port (baud rate=9600, CH340 driver)
Method: Pass string(string)
Function : Get string from buffer()

I believe there is a special B4A library that can see the CH340 chip as a virtual serial port for text strings. But I can't find it here.
Excuse me! I understand that this is very, very simple, and I'm stupid. This is the basics, just open the port and send or receive lines of text! But I'm completely confused! I'm ashamed and I'm asking for help.

Help me please!
This is probably too simple, because I wrote this 4-line code for a large computer in C#, and got completely confused when I tried to find drivers and libraries for Android basic.

Many thanks in advance to everyone!
Last edited:


Licensed User
Longtime User
Hello All.

From what I read, the main problem is that the phone recognizes the serial port of the CH340 and then has access from the app.

I can't help you with that, but you may be interested in doing it via wifi (ESP-01) or bluetooth.

Please note that not all phones have the OTG option.

All the best.

Hola All.

Por lo que leo, el principal problema es que el teléfono reconozca el puerto serie del CH340 y después tener acceso desde la app.

No puedo ayudate con eso, pero quizás te interese hacerlo por wifi (ESP-01) o bluetooth.

Ten en cuenta que no todos los teléfono tienen la opción de OTG.

Un saludo.
Upvote 0


Yes, I understand that it is easier to do this through bluetooth or Wi-Fi.
However, we are talking about very cheap micro-computers based on the Chinese Ardruino Nano-328P (340) board.
The matchbox-sized module has a simple Basic interpreter on board, and a bunch of connectors for connecting children's Lego, OLED diodes, sensors and other toys.
These boxes are used by children from 9 to 12 years old in the lessons of computer science, physics and elementary chemistry, to build the simplest experiments with control.
The fact is that in some of our schools they decided to teach all subjects at once with the help of experiments, almost without textbooks.
Therefore, schools ordered such very cheap boxes and filled them with Basic Interpreters, as well as a full-fledged U-Lisp.
First, the kids play with BASIC and all sorts of sensors, test tubes, thermometers. And when they understand how it works, BASIC is taken away from them and they are given the same boxes with Lisp. This is so that they learn to think non-frost, and train the flexibility of the mind.
I am the son of an elementary school teacher.
And I see how difficult it is to communicate with these modules through the Standard Terminal program.

The problem is that it is very inconvenient for children and adults to work from the command line of a regular terminal.
In addition, only the teacher has a computer in the classroom.
And 25 students have good Android tablets donated to everyone from the state.
These tablets have textbooks, a knowledge base, a connection to the teacher's computer and an OTG port.

My idea is to write a beautiful code editor (Basic and Lisp) in B4A with syntax highlighting and interaction windows.
Then it will be possible to connect ardruino-krobochki to OTG tablets.

I tried to open a serial OTG port on MIT APP Inverter-2 and on Android Studio.
This is easy to do. But Meat APP is a primitive program on which it is not possible to implement full-fledged code editor logic and syntax highlighting.
And Android Studio is too complicated for me.. I'm still a teenager)))

That's why I want to make my project in Basic B4A.

Many thanks to everyone who will tell me how?
Upvote 0