UART on XIAO ESP32S3 using Micropython

I’ve installed the Micropython specified here to my XIAO ESP32-S3: MicroPython for XIAO ESP32S3 Sense | Seeed Studio Wiki

Can anyone give me some simple test code to test the UART in loopback mode? - I can’t get the UART to work.

I’m not sure I’m using the right pins. I’ve tried a lot of different combinations. Do I need to use the pin numbers of the ESP32 or the pins on the actual board? A working example that runs on the same hardware would be much appreciated.

from machine import Pin, UART
import time

# UART
uart = UART(2, tx=49, rx=50, baudrate=9600)

print(uart)

uart.write('HELLO UART')

# Wait for input
while True:
    if uart.any():
        data = uart.read()
        print(data)
        time.sleep(1)

Hi there,
Try the GPIO pin numbers. It will go.!
HTH
GL :slight_smile: PJ :v:

Yes, that’s it! :clap: uart = UART(2, tx=43, rx=44, baudrate=9600)

Thanks very much!

1 Like