working with multiple serial devices
working with multiple serial devices
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?
Re: working with multiple serial devices
You can and should use the PIO for implementing additional uarts. The example code is available.
Re: working with multiple serial devices
ah, excellent, I have some reading to do! That is exactly the pointer I needed.
Re: working with multiple serial devices
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.
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.