UART RFID on Portenta

Hi, I have a WL134 RFID reader with me that works fine on an Arduino Uno. I wanted to try working with it on a Portenta. I’ve started with trying something very preliminary like this:

from machine import UART

uart = UART(1, 9600)

while True:
    print(uart.read())

The above code gives me a repeated None output, even when a compatible RFID tag is around the antenna. A user on this RPi SO post experienced having a similar issue that they fixed using another micropython package called pigpio (GitHub - joan2937/pigpio: pigpio is a C library for the Raspberry which allows control of the General Purpose Input Outputs (GPIO).).

Is there a way to achieve what I want using machine.UART()? Asking since it’s a very simple experiment and intuitively machine.UART() should be able to help.

I’ve ensured the connections are correct.

Regards,
PC

Hi, please make sure the UART you want to use is hooked up to the right RX pins on the Arduino Portenta. Then, there are some timeout settings for the UART you need to setup: class UART – duplex serial communication bus — MicroPython 1.23 documentation

You should specify the timeout and per character timeout.

Hi @kwagyeman,

I was experimenting with these parameters after posting the question but have had no luck yet.

from machine import UART

uart = UART(1, 9600)
uart.init(9600, bits=8, parity=None, timeout=250, timeout_char=100)

while True:
    print(uart.read())

The Tx pin of the RFID reader is connected to pin D13/PA10 of the Portenta; I have confirmed that this is referred to by UART(1). I have also been referring to the source code of Lora library for some reference too since UART is used there.

PC

Are the grounds of both devices connected too?

You can easily check if the UART is working on the Portenta by doing a loop back by adding a uart.write() call with a string and attach the TX to the RX pin.

Hi, sorry I took forever to get back on this.

I took your suggestion and tested the UART; all is well. Further investigating why this could be happening with the Portenta given it’s working well on Uno.

from machine import UART

uart = UART(1, 9600)
uart.init(9600, bits=8, parity=None, timeout=250, timeout_char=100)



while True:
   uart.write("HW")
   print(uart.read())

PC

Hi, okay, let me know if you have any questions given the OpenMV Cam side is fine.