Access to all 3 UARTS on ESP32



  • Hello,

    I have an application were I need a UART, REPL and SD Card. It would appear that the SD card uses pins from UART 1, and UART 0 us used by the REPL and for programming. There is a 3rd UART on the ESP32 but it does not appear to be available on the Pycom modules.

    Is there access to UART2? If so how can it be configured?

    Thanks



  • @colateral
    There aren't default pins for UART2 as far as know, just choose them at initialisation with pins=(TXD, RXD, RTS, CTS) option.



  • For UART0 and UART1 pins are mentioned in pinout digram, but what are the default pins for UART2 ? Is it hardware or software?

    Does anybody tried UART2 and which pins?



  • @jmarcelino

    From a product support perspective complexity isn't usually the issue, clarity is. I have experiences with similar products so I can only image how people new to this might think. It is simple, but it was not even clear it was possible with Micropython. If it was not for this more direct answer and some obscure post I had to dig around for, I would not have been able to confirm it.

    Also I am guessing that the input only pins should not have outputs mapped to them.

    All I am saying is that if this subject is clearer it could of save me and other people time, and increase confidence in the Pycom products.



  • @travist
    It’s not very complex, you can remap all Pycom supported peripherals except the SD card.



  • Thanks

    This all makes sense, but left unclear in the documentation. Maybe a section on pin mux fictionality and what peripherals can change pins and which cannot.



  • @TravisT
    To complete the answer to your question;
    Yes, UART2 is accessible even though the pycom documentation only mentions UART 0 & 1, simply use a 2 in the place of 1 or 0.



  • Thanks,

    I have found hints of this many places, but nothing seems very explicit. To me when I read the documentation on UART it does not seem much different than many MCU that are implying to use any default UART pins. I guess this is why I assumed it was not that straight forward.

    I feel like it would be nice to have a section in the manual that explicitly talks about PIN assignments and reassignments. Even if it is obvious after you understand it, just so there is no confusion for less experiences, or new adopters.



  • @travist
    It’s easy because the ESP32 has an internal multiplex. You can do this for SPI and I2C as well, only very high speed ports (e.g Ethernet RMII) don’t.

    The explanation is on the UART doc page for UART.init()

    https://docs.pycom.io/chapter/firmwareapi/pycom/machine/UART.html

    pins is a 4 or 2 item list indicating the TXD, RXD, RTS and CTS pins (in that order). Any of the pins can be None if one wants the UART to operate with limited functionality. If the RTS pin is given the the RX pin must be given as well. The same applies to CTS. When no pins are given, then the default set of TXD (P1) and RXD (P0) pins is taken, and hardware flow control will be disabled. If pins=None, no pin assignment will be made.



  • Thanks,

    This sounds almost too easy. Can you provide more concrete example or link to documentation using Micropython to reassign pins?

    I guess I figured that it was more involved and possibly a compile time configuration.



  • @travist
    As with other peripherals you can remap the UART1 pins to ones which don’t conflict, just add the additional parameter pins=(TXD, RXD, RTS, CTS) when you init the UART, replacing TXD,RXD etc with your desired pin numbers


 

Pycom on Twitter