Konubinix' opinionated web of thoughts

Connect Android and a Board With a Single Microcontroller

Fleeting

Android and a board with a single microcontroller

Installed

Pydroid 3 Educational IDE for Python 3_v2.22_arm_apkpure.com.apk

And followed the instructions in : https://github.com/jacklinquan/usbserial4a

with arduino

void setup() {
  // Start the serial communication at 9600 baud rate
  Serial.begin(9600);
}

void loop() {
  // Check if there's any data available to read
  if (Serial.available() > 0) {
    // Read a single character from the serial input
    char incomingChar = Serial.read();

    // Send the character back to the serial output
    Serial.print("Received: ");
    Serial.println(incomingChar);
  }
}
Sketch uses 1518 bytes (4%) of program storage space. Maximum is 32256 bytes.
Global variables use 198 bytes (9%) of dynamic memory, leaving 1850 bytes for local variables. Maximum is 2048 bytes.

Used platform Version Path
arduino:avr   1.8.6   /home/sam/.arduino15/packages/arduino/hardware/avr/1.8.6
New upload port: /dev/ttyACM0 (serial)

Checking using the PC with picocom /dev/ttyACM0

Also I tried with

import serial

arduino = serial.Serial(port='/dev/ttyACM0', baudrate=9600, timeout=1)
arduino.write(b"a")
return (arduino.readlines())
[b'Received: a\r\n']

Using the file usbserial4a_ui_example.py, I get this

That is very promising.

with wemos/lolin d1

from machine import UART
import time
import machine

import sys

led = machine.Pin(2, machine.Pin.OUT)
led.off()  # on
time.sleep(2)
led.on()  # off

while True:
    # Check if there's incoming data on the USB serial connection
    incoming_char = sys.stdin.read(1).strip()  # Read one character from USB
    if incoming_char:
        print(f"Received: {incoming_char}")

    time.sleep(1)

Checking using the PC with picocom -b 115200 /dev/ttyUSB0

import serial

esp8266 = serial.Serial(port='/dev/ttyUSB0', baudrate=115200, timeout=1)
esp8266.write(b"test")
return (esp8266.readlines())
[b'Received: t\r\n', b'Received: e\r\n', b'Received: s\r\n', b'Received: t\r\n']

I changed the example to use the 115200 instead of 9600, and I can see the communication.

Notes linking here