LinuxCommandLibrary

mpremote

Control MicroPython devices over serial

TLDR

List all connected MicroPython devices

$ mpremote connect list
copy

Open an interactive REPL session with a connected device
$ mpremote connect [device]
copy

Run a local script on a connected device
$ mpremote run [path/to/script.py]
copy

Mount a local directory to the device
$ mpremote mount [path/to/directory]
copy

Install a mip package on the device
$ mpremote mip install [package]
copy

SYNOPSIS

mpremote [options] command [args...]

PARAMETERS

--port port
    Specify the serial port of the MicroPython device.

--baud baudrate
    Set the baud rate for the serial connection (default: 115200).

--network host:port
    Connect to the MicroPython device over a network socket.

--web-repl host:port
    Connect to the MicroPython device using WebREPL.

--pwd directory
    Change the current working directory on the remote device.

--help
    Show help message and exit.

--version
    Show program's version number and exit.

DESCRIPTION

The mpremote command provides a comprehensive tool for interacting with MicroPython devices over a serial connection, network socket, or WebREPL. It enables users to execute Python code directly on the device, transfer files, manage the file system, and debug MicroPython applications.

It's primarily designed to streamline the development workflow for MicroPython projects, eliminating the need for manually copying files or repeatedly resetting the device for testing. mpremote integrates features like file system manipulation (copying, listing), code execution, REPL access, and script automation.

The tool can be extended by subcommands that handle specific functionalities or by creating user-defined subcommands for custom workflows. It simplifies managing MicroPython devices through its interactive and scripting capabilities, making it essential for developers working with embedded systems and IoT projects.

CAVEATS

Network and WebREPL connections require the corresponding services to be enabled on the MicroPython device.

COMMON SUBCOMMANDS

Frequently used subcommands include:
repl: Enter the MicroPython REPL.
exec code: Execute Python code on the device.
run script.py: Run a Python script from the host machine on the device.
cp src dest: Copy files between the host and the device.
ls [path]: List files in a directory on the device.
reset: Perform hard or soft reset on the board.

FILE SYSTEM SYNCHRONIZATION

The mpremote cp command is extremely useful for synchronizing code changes. It allows for quick iteration during development, copying updated files to the MicroPython device without manual intervention.

HISTORY

mpremote was developed as part of the MicroPython project to provide a robust and convenient way to interact with MicroPython devices. Its usage has grown alongside the popularity of MicroPython in embedded systems and IoT development.

SEE ALSO

picocom(1), screen(1), minicom(1)

Copied to clipboard