Claude Code and Codex with a Raspberry Pi Pico (MicroPython)

A Pico running MicroPython has one USB serial port, and its REPL can have one user at a time: you, Thonny, mpremote or a coding agent. NeuroTerm is a serial and SSH terminal for embedded developers who work with Claude Code and Codex. It is free for individuals, at work too, and runs on Windows and Linux. Its serial tab keeps the Pico’s REPL open, and Claude Code or Codex works in that same REPL with you.

Why the agent and the Pico get in each other’s way

Ask Claude Code to try something on the Pico and it reaches for mpremote. While Thonny or your terminal has the port open, that ends in failed to access … (it may be in use by another program). When the port is free, every mpremote run or exec stops your program with Ctrl+C and soft-resets the board, so the state you were looking at is gone. And mpremote repl, like any serial monitor, never returns, so the agent’s tool call waits until you kill it.

The two mpremote errors are explained on their own page: mpremote: could not enter raw repl, or port in use.

Set it up

  1. Flash MicroPython if the Pico does not have it: hold BOOTSEL while you plug it in, then drag the UF2 onto the RPI-RP2 drive (RP2350 on a Pico 2). The Pico reboots into MicroPython (Raspberry Pi documentation).
  2. In NeuroTerm choose New session, then Serial, and pick the Pico’s port: a COM port on Windows, /dev/ttyACM0 on Linux. Connect and press Enter for the >>> prompt. Save it as a profile.
  3. Open Settings → Coding agents → Connect a coding agent, choose Connect… for this computer and keep Terminal Use on.
  4. Start claude or codex in a NeuroTerm Local or WSL tab (Codex on Windows: a WSL tab) and ask, for example, “In my Pico tab, print the firmware version and blink the LED three times.”

What the agent does in the REPL

The agent reads what the REPL prints in the tab, including your own program’s output and tracebacks. It types into it: text, and keys such as Ctrl+C to stop a program, Ctrl+E for paste mode and Ctrl+D to finish the paste or soft-reset, waiting for >>> before it goes on. You see every line it sends in the same tab.

Reading needs no approval. Before the agent types, the tab shows the request and waits for Allow or Deny; no answer in 45 s means no. When it needs mpremote itself, for mpremote cp or mip install, it asks to borrow the port: NeuroTerm closes it so the agent’s mpremote can use it, and reopens it in the tab when the agent gives it back. Reopening may reset the board.

On Windows, an agent in a WSL tab can read and type in the Pico’s COM-port tab without the USB device being passed into WSL. An mpremote run inside WSL still needs the device passed in.

When the Pico restarts

machine.reset(), a new UF2 or a pulled cable makes the Pico’s USB serial port disappear. NeuroTerm watches for a USB serial device by its USB serial number, or by its vendor and product ID, and the same tab reconnects when the device comes back, even under a new port name (Auto-reconnect). The agent then reads the MicroPython banner in the same tab.

Programs written with the Pico C SDK that print over USB show up in a serial tab the same way, and the agent reads them the same way.

Other ways to do it

  • For scripts that run and exit, mpremote alone is enough: tell the agent in CLAUDE.md to close other programs on the port first and never to run mpremote repl.
  • MCP servers built on mpremote, such as mpremote-mcp, give an agent board tools without a terminal; then the agent, not you, holds the port.
  • For a first day with MicroPython, Thonny’s editor and built-in REPL are the simplest start.