Ok this is from my micropython version which is UART enable
#define MICROPY_HW_ENABLE_UART_REPL (1) // UART enable
#define MICROPY_HW_ENABLE_USBDEV (0) // USB OFF (I'm using it in USB_HOST_MODE)
The script using Pyserial,
import serial
com = serial.Serial('/dev/serial0',baudrate=115200,timeout=1)
#Send import command via /dev/serial0
com.write("import os\r".encode("utf-8"))
returnChars = com.read(100).decode("utf-8")
print(returnChars)
#"Send os.uname via /dev/serial0
com.write("os.uname()\r".encode("utf-8"))
returnChars = com.read(200).decode("utf-8")
print(returnChars)
#Send help('modules') via /dev/serial0
com.write("help('modules')\r".encode("utf-8"))
returnChars = com.read(3000).decode("utf-8")
print(returnChars)
And the result when I run it from the Pi
pi@benchpi4:~ $ python3 confirmserial0.py
import os
>>>
os.uname()
(sysname='rp2', nodename='rp2', release='1.19.1', version='v1.19.1-375-ge90b85cc9-dirty on 2022-09-08 (GNU 8.3.1 MinSizeRel)', machine='Raspberry Pi Pico with RP2040')
>>>
help('modules')
__main__ gamepad uasyncio/funcs ujson
_boot gc uasyncio/lock umachine
_boot_fat math uasyncio/stream uos
_onewire micropython ubinascii urandom
_rp2 neopixel ucollections ure
_thread onewire ucryptolib uselect
_uasyncio rp2 uctypes ustruct
builtins uarray uerrno usys
cmath uasyncio/__init__ uhashlib utime
dht uasyncio/core uheapq uzlib
framebuf uasyncio/event uio
Plus any modules on the filesystem
>>>
You should read
Raspberry Pi UART. This tell that /dev/serial0 will be always the primary UART which depends of the Pi model.
Old PI use /dev/ttyAMA0 on GPIO14&15 but the PI3 &PI4 use /dev/ttyS0
regards,
Daniel Perron