working with multiple serial devices

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
alanbell
Posts: 8
Joined: Mon Mar 29, 2021 9:50 am

working with multiple serial devices

Post by alanbell » Thu Apr 22, 2021 3:52 pm

I want to read a position from a GPS module, read a value from an air quality sensor, then send that data over a serial GSM module. Given that there are 2 UARTs and one is kind of handy for REPL, what is the best approach here? Can I do something like point UART1 at GPIO4/5 for a bit then destroy it and reconfigure it to point to GPIO8/9 and talk to a different device? Should I be looking at SPI to UART bridges or doing software UARTs on other pins?

Online
User avatar
Roberthh
Posts: 2637
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: working with multiple serial devices

Post by Roberthh » Thu Apr 22, 2021 6:05 pm

You can and should use the PIO for implementing additional uarts. The example code is available.

alanbell
Posts: 8
Joined: Mon Mar 29, 2021 9:50 am

Re: working with multiple serial devices

Post by alanbell » Thu Apr 22, 2021 6:26 pm

ah, excellent, I have some reading to do! That is exactly the pointer I needed.

alanbell
Posts: 8
Joined: Mon Mar 29, 2021 9:50 am

Re: working with multiple serial devices

Post by alanbell » Sun Apr 25, 2021 11:48 am

Based on the pio_uart_rx.py example code I now have it reading from a GPS module on a normal GPIO pin, which is absolutely fantastic, I did find that the uart_rx_mini function works perfectly for ages, but the uart_rx function seems prone to locking up.

I am wondering if the PIO system should be used as more of a device driver rather than just a UART, so that it would understand the data coming back from the device and for example return a data structure with the last read latitude and longitude and time rather than returning the raw serial string. It seems to have a lot of potential for simplifying the application running on the core.

Post Reply