Claude Code hangs on idf.py monitor or pio device monitor
A serial monitor runs until someone presses its exit key, so a coding agent that starts one waits for good. 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 ESP32’s port open, and Claude Code or Codex reads the log there instead of starting a monitor.
What happens
You flash the board and ask the agent to check that it boots. It runs idf.py monitor, pio device monitor, arduino-cli monitor or espflash monitor, and the session stops answering. Claude Code issue #23745 (February 2026) reports exactly this with espflash monitor on an ESP32, and #6237 the same for tty devices in general.
Why it happens
- A monitor never ends by itself. ESP-IDF Monitor quits on Ctrl+] (ESP-IDF docs) and
pio device monitoron Ctrl+C (PlatformIO docs). The agent’s shell has no keyboard to press them, so the tool call does not come back. - By default ESP-IDF Monitor resets the chip through the DTR and RTS lines when it connects. Each new attempt restarts the board, and the boot you wanted to see has already scrolled past in a monitor that is gone.
- While your own monitor holds the port, the agent’s monitor cannot open it, and the agent tries another way.
What works without new tools
- Close your own monitor before you ask the agent to read the port, and tell it so.
- Write in
CLAUDE.md(orAGENTS.mdfor Codex) that it must never start a monitor, and give it a read that ends, like the script below. - Run ESP-IDF Monitor with
--no-resetwhen you want to watch without restarting the board.
# read_log.py: print 10 seconds of the board's log, then exit
import sys, time, serial # pip install pyserial
port = sys.argv[1] if len(sys.argv) > 1 else "/dev/ttyUSB0"
with serial.Serial(port, 115200, timeout=1) as s:
end = time.time() + 10
while time.time() < end:
line = s.readline()
if line:
print(line.decode(errors="replace"), end="")Opening the port can still reset a dev board through its auto-reset circuit, so the script may catch a fresh boot rather than the moment you meant.
With a coding agent in NeuroTerm
Your serial tab keeps the port open and the log. Claude Code or Codex started in a NeuroTerm Local or WSL tab reads that tab’s new output through Terminal Use, NeuroTerm’s MCP server, so it never starts a monitor. Lines NeuroTerm recognises, such as a Guru Meditation Error, a task watchdog or an ESP32 reset reason, reach the agent among the markers of the output it reads, with pattern markers on.
Reading needs no approval. Before the agent types, resets the board through the port’s control lines or borrows the port, the tab shows the request and waits for Allow or Deny; no answer in 45 s means no. To flash, it borrows the port: NeuroTerm closes it so the agent’s idf.py flash, esptool or pio run -t upload can use it, and reopens it in the tab when the agent gives it back. Reopening may reset the board.