Skip to main content

Tool for interacting remotely with MicroPython devices

Project description

mpremote -- MicroPython remote control

This CLI tool provides an integrated set of utilities to remotely interact with and automate a MicroPython device over a serial connection.

The simplest way to use this tool is:

mpremote

This will automatically connect to a USB serial port and provide an interactive REPL.

The full list of supported commands are:

mpremote connect <device>         -- connect to given device
                                     device may be: list, auto, id:x, port:x
                                     or any valid device name/path
mpremote disconnect               -- disconnect current device
mpremote mount <local-dir>        -- mount local directory on device
mpremote eval <string>            -- evaluate and print the string
mpremote exec <string>            -- execute the string
mpremote run <file>               -- run the given local script
mpremote fs <command> <args...>   -- execute filesystem commands on the device
                                     command may be: cat, ls, cp, rm, mkdir, rmdir, sha256sum
                                     use ":" as a prefix to specify a file on the device
mpremote repl                     -- enter REPL
                                     options:
                                         --capture <file>
                                         --inject-code <string>
                                         --inject-file <file>
mpremote mip install <package...> -- Install packages (from micropython-lib or third-party sources)
                                     options:
                                         --target <path>
                                         --index <url>
                                         --no-mpy
mpremote help                     -- print list of commands and exit

Multiple commands can be specified and they will be run sequentially. Connection and disconnection will be done automatically at the start and end of the execution of the tool, if such commands are not explicitly given. Automatic connection will search for the first available serial device. If no action is specified then the REPL will be entered.

Shortcuts can be defined using the macro system. Built-in shortcuts are:

  • a0, a1, a2, a3: connect to /dev/ttyACM?
  • u0, u1, u2, u3: connect to /dev/ttyUSB?
  • c0, c1, c2, c3: connect to COM?
  • cat, ls, cp, rm, mkdir, rmdir, df: filesystem commands
  • reset: reset the device
  • bootloader: make the device enter its bootloader

Any user configuration, including user-defined shortcuts, can be placed in .config/mpremote/config.py. For example:

# Custom macro commands
commands = {
    "c33": "connect id:334D335C3138",
    "bl": "bootloader",
    "double x=4": {
        "command": "eval x*2",
        "help": "multiply by two"
    }
}

Examples:

mpremote
mpremote a1
mpremote connect /dev/ttyUSB0 repl
mpremote ls
mpremote a1 ls
mpremote exec "import micropython; micropython.mem_info()"
mpremote eval 1/2 eval 3/4
mpremote mount .
mpremote mount . exec "import local_script"
mpremote ls
mpremote cat boot.py
mpremote cp :main.py .
mpremote cp main.py :
mpremote cp -r dir/ :
mpremote sha256sum :main.py
mpremote mip install aioble
mpremote mip install github:org/repo@branch
mpremote mip install gitlab:org/repo@branch

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpremote-1.24.1.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

mpremote-1.24.1-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

Details for the file mpremote-1.24.1.tar.gz.

File metadata

  • Download URL: mpremote-1.24.1.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.7

File hashes

Hashes for mpremote-1.24.1.tar.gz
Algorithm Hash digest
SHA256 1a3c16d255748cfe54d4a897908651fc8286233173f7c7b2a0e56ae4b9fa940e
MD5 ca4ebce7c40e9c3af503e238cff2cd1a
BLAKE2b-256 178f1524e4ad13bb3169f10b2e859753114a2bae3ae6944e1d1e48e96838c1ce

See more details on using hashes here.

File details

Details for the file mpremote-1.24.1-py3-none-any.whl.

File metadata

  • Download URL: mpremote-1.24.1-py3-none-any.whl
  • Upload date:
  • Size: 29.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.7

File hashes

Hashes for mpremote-1.24.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d3ae3d0a0ae7713c537be2b6afadd11c7cde5f1750ea1260f6667bb80071b15b
MD5 a21ffbde98b2da40273687419ac8b90c
BLAKE2b-256 ee0839e3cf836602825eefa53127e7b8d3a64cded8d3f639f9c67d823583e029

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page