Amigo UART

I have tried to configure Grove 1 on Amigo as a UART to connect to a microbit. I have this working for MaxiDuino with the correct pin map assignments but not for Amigo. Grove 1 on Amigo uses IO5 for TX and IO4 for RX. I am only using thre of the four Grove wires (Yellow, White, GND) with a cross over of white & yellow to the microbit. Where am I going wrong with configuring the Amigo as a UART?
The key code lines are:
fm.register(5, fm.fpioa.UART1_TX)
fm.register(4, fm.fpioa.UART1_RX)

from machine import UART

uart_A = UART(UART.UART1, 115200, 8, 1, 0, timeout=1000, read_buf_len=4096)

1 Like

I had the same problems, I tried all of the grove ports and could not initialize UART on any of them. One set would hang, and the others just wouldn’t work.
However on the SP-MOD ports I can get UART to work reliably on MOST of them. The bottom middle two pins on each SP-MOD always works flawlessly.

After searching a bit more I think the data pins on the Grove ports are also used by other things.
https://dl.sipeed.com/MAIX/HDK/Sipeed-Amigo

https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=zh-CN&sp=nmt4&tl=en&u=https://maixpy.sipeed.com/zh/develop_kit_board/maix_amigo.html&usg=ALkJrhhTflLhyzK9WpTgXeN4MUb3bx04Kg

I can kind of confirm that some of the pins are already in use.
I got an ESP8266 connected via UART over the SPMOD connector – only one of them. Running on the other SPMOD connector crashes when I try to pull down the ESP8266’s GPIO0 (GPIOHS6 on the other PMOD:

#################################
#### bottom / right SPMOD    ####
#################################
#	29 - gpio2
#	28 - gpio0
#	08 - reset
#	30 - ch_en
#	22 = TX
#	25 = RX

    def setupUART(TX=12,RX=6,id=2,speed=115200,bits=8,parity=None,stop=1,timeout=1000,buf=4096):
        from fpioa_manager import fm
        from machine import UART
        if(id==1):
            dev = UART.UART1
            txpin = fm.fpioa.UART1_TX
            rxpin = fm.fpioa.UART1_RX
        elif(id==2):
            dev = UART.UART2
            txpin = fm.fpioa.UART2_TX
            rxpin = fm.fpioa.UART2_RX
        elif(id==3):
            dev = UART.UART3
            txpin = fm.fpioa.UART3_TX
            rxpin = fm.fpioa.UART3_RX
        fm.register(TX, txpin)
        fm.register(RX, rxpin)
        uart_dev = UART(dev, speed, bits, parity, stop, timeout = timeout, read_buf_len=buf)
        return(uart_dev)

    from Maix import GPIO
    import sys
    b2 = GPIO(GPIO.GPIOHS29,mode=GPIO.PULL_UP)
    b0 = GPIO(GPIO.GPIOHS28,mode=GPIO.PULL_DOWN)
    t2 = setupUART(TX=22,RX=25,id=2)
    from _thread import start_new_thread
    from time import sleep_ms
    def serialReader():
        while True:
            if(t2.any()>0):
                print(t2.read().decode(),end='')
            sleep_ms(20)
    reader = start_new_thread(serialReader,())
    def serialWriter():
        sendBuf = []
        while True:
            c = sys.stdin.read(1)
            print(c,end='')
            if c == '\n':
                t2.write(''.join(sendBuf) + '\r\n')
                sendBuf = []
            else:
                sendBuf.append(c)
            sleep_ms(10)
            
    serialWriter()