Serial Communication with Raspberry Pi Pico in Windows 10/11 via WSL

Saket Upadhyay
InfoSec Write-ups
Published in
3 min readMay 30, 2022

--

Raspberry Pi Pico

“Raspberry Pi Pico is a low-cost, high-performance microcontroller board with flexible digital interfaces” ~raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico

The microcontroller can be programmed in MicroPython or C/C++. For more information, check the Official Website.

Setting up WSL 🪟

If you haven't already, set up WSL in your Windows 10/11 machine by following Microsoft’s official guide :

Downgrading WSL to version 1 ⬇️

For some reason, serial communication with minicom does not work in WSL version 2, hence we will need to downgrade our WSL instance to version 1.

First check what’s your WSL container version number by wsl --list -v :

If the number below VERSION is 2, you can convert it back to version 1 by-

wsl --set-version <DISTRO_NAME> <TARGET_VERSION>

Check the version again by wsl --list -v :

Now, we can see that our Ubuntu-20.04 container is set at version 1, we can proceed with next steps.

Installing minicom

Minicom is a text-based serial port communications program. It is used to talk to external RS-232 devices such as mobile phones, routers, and serial console ports. ~ https://help.ubuntu.com/community/Minicom

Fire up the WSL instance in your terminal and type sudo apt-get update && sudo apt-get install minicom to install minicom. We don’t need to configure anything as our serial connection is virtual hence it is not limited by baud rate and other settings.

Communication with Pico 💡

To communicate with raspberry Pi Pico, make sure that MicroPython Image is flashed to the board and it is connected to the computer with proper USB cable. To learn how to flash micropython to Pico READ THIS DOCUMENT.

Finding the virtual serial port

After connecting the pico to your Windows host computer you need to find the virtual serial port it is connected to. Run the following commands in your PowerShell to find the COM port.

In this case the port is COM3, which will translate to /dev/ttyS3 inside WSL. This relation can also be expressed by — COM(ɳ) -> /dev/ttyS(ɳ) [∀ ɳ∈N] .

Connecting via minicom

Once COM port number is known, we can open our WSL instance and start the connection with minicom -D /dev/ttyS3 by replacing ttyS3 with respective ɳ of COM port. After connection ,press CTRL+D to initiate soft reboot and then press CTRL+B to exit to MicroPython instance.

Cheers! Now you can start interacting with the device in Micro Python🐍.

--

--