Is it possible to have two serial ports open on the Pico with one USB connection?

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
electronut
Posts: 6
Joined: Mon Dec 13, 2021 3:01 am

Is it possible to have two serial ports open on the Pico with one USB connection?

Post by electronut » Tue Jun 14, 2022 2:55 am

When I plug in the RP2040 Pico via USB, I want to see two serial ports that I can communicate with. One will be used to communicate with the Pico, and the other will be used as a serial passthrough for a second device connected to the Pico. I'd appreciate any suggestions on how to go about implementing this using MicroPython. Thanks!

Filip_KONAX
Posts: 16
Joined: Wed Jun 08, 2022 1:05 pm

Re: Is it possible to have two serial ports open on the Pico with one USB connection?

Post by Filip_KONAX » Tue Jun 14, 2022 10:44 am

Hi
Sorry for the late answer. Maybe you've already found the answer. If not, here's a pointer to the solution:
This is possible, but not without making your own version of MicroPython. Fortunately others had the same question before you (not me!).
I've found this interesting link for you:
https://forums.raspberrypi.com/viewtopi ... 2#p1979332
Good luck!

electronut
Posts: 6
Joined: Mon Dec 13, 2021 3:01 am

Re: Is it possible to have two serial ports open on the Pico with one USB connection?

Post by electronut » Wed Jun 15, 2022 2:45 am

Thanks, Filip. I might as well as drop to C for implementing this. I found that TinyUSB has a dual CDC port example:

https://github.com/hathach/tinyusb/tree ... dual_ports

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Is it possible to have two serial ports open on the Pico with one USB connection?

Post by pythoncoder » Wed Jun 15, 2022 9:45 am

What about the examples using the PIO to implement a UART? See this link.
Peter Hinch
Index to my micropython libraries.

Filip_KONAX
Posts: 16
Joined: Wed Jun 08, 2022 1:05 pm

Re: Is it possible to have two serial ports open on the Pico with one USB connection?

Post by Filip_KONAX » Mon Jun 20, 2022 6:58 am

That's an option indeed if you don't need the rest of the features you get using MicroPython
electronut wrote:
Wed Jun 15, 2022 2:45 am
Thanks, Filip. I might as well as drop to C for implementing this. I found that TinyUSB has a dual CDC port example:

https://github.com/hathach/tinyusb/tree ... dual_ports

Filip_KONAX
Posts: 16
Joined: Wed Jun 08, 2022 1:05 pm

Re: Is it possible to have two serial ports open on the Pico with one USB connection?

Post by Filip_KONAX » Mon Jun 20, 2022 7:00 am

Hi Peter, the question was to have two virtual (CDC) serial ports on one USB connection, don't see how you can do that using PIO :?
pythoncoder wrote:
Wed Jun 15, 2022 9:45 am
What about the examples using the PIO to implement a UART? See this link.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Is it possible to have two serial ports open on the Pico with one USB connection?

Post by pythoncoder » Mon Jun 20, 2022 8:17 am

Ah, sorry. I didn't even know that such a thing was possible. :(
Peter Hinch
Index to my micropython libraries.

Post Reply