1

I read that the Pi Pico/RP2040 has 2 UARTs.

If I want to send data from a computer to a Pi Pico, how should I create a UART that uses USB? Micropython expects pin numbers to create a UART. If I use one UART to receive from the PC and one to transmit to the other Pico via wires,will repl still work? Does it also not use UART/serial? In CircuitPython, the serial/UART is directly available as UART = usb_cdc.data. What happens if I print some stuff in Python code? Is it mixed with UART data?

I want to basically use the Pico as a USB to TTL adapter, but I am confused about how to read data sent from the PC to USB.

JRE
  • 67,678
  • 8
  • 104
  • 179
Suresh Subedi
  • 121
  • 1
  • 6

2 Answers2

2

To use the default usb serial connection, you will need to use "sys.stdin" and "sys.stdout". Stdout is as simple as "print()". Stdin requires some polling or looping, or using any number of online implementations that wrap around the normal calls. It's not an elegant system.

It does not show up as an independent uart in micro or circuit python.

Passerby
  • 72,580
  • 7
  • 90
  • 202
  • I was able to use seperate serial for data. It does show up as independent uart and I am able to connect to it with arduino ide serial monitor. That is also mentioned here: https://learn.adafruit.com/customizing-usb-devices-in-circuitpython/circuitpy-midi-serial – Suresh Subedi Apr 21 '22 at 18:57
  • @SureshSubedi okay, that's a different method. There you are changing the RP to use USB CDC instead of the standard debugging serial connection. The Print would still go to the debug serial while the usb cdc serial would be separate. – Passerby Apr 21 '22 at 19:29
0

The Pico has built-in USB, so the serial connection from the PC does not use the UART hardware.

I'm not familiar with MicroPython, but there will be a method to read characters from USB serial somewhere. This will be distinct from the UART data.

DamienD
  • 3,093
  • 1
  • 14
  • 23
  • Your accessment seems to be correct. I am able to use two seperate serials via usb: repl to print info and serial to send data to pico with other serial program with circuit python. I am also able to send data from one pico to another with uart. Since I am using three serials and it's still working, only uart that's physically wired seems to count towards the limit of 2 uarts. Cheers. – Suresh Subedi Apr 21 '22 at 18:54