Main Menu

search

You are here

Terminal with RP2040

[last updated: 2024-09-17]
RP2040-Zero home page
MicroPython on RP2040
-----------------------------

This page rough and incomplete ...

  • Interacting with the MicroPython on your zero:
    • REPL: = "read-evaluate-print loop"
      This mode allows you to connect to your zero via USB connector on the board, run a terminal program on your host PC,
        Read: type in code (followed by <cr>)
        Evaluate: that is evaluated as python code and executed,
        Print: results are printed back to the terminal,
        Loop: and it then loops back to waiting for more text.

      • The zero has a virtual USB serial port that should show up on your host PC as /dev/ttyACM0 or something similar.
        List ports with:
          $ ls /dev/tty*
          On my system it indeed showed up as /dev/ttyACM0

      • Install the minicom module to access this port:
          $ sudo apt install minicom
      • Open the minicom port (using the port ID on your PC):
          $ minicom -o -D /dev/ttyACM0

        If you do this before the RP-2040 is plugged in, there will be no ACM0 port to access, so it will just close and revert to $ prompt.

        If you plug in the RP-2040 first, then open minicom, my system printed::

          Welcome to minicom 2.8
          OPTIONS: I18n
          Port /dev/ttyACM0, 10:33:01
          Press CTRL-A Z for help on special keys


        Press enter key a few times if necessary, and you should see a ">>>" prompt.

      • At this point, if you type ctrl-D, your zero should reboot and print out its firmware version and build date.
        On my system it printed:
          MPY: soft reboot
          MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico with RP2040
          Type "help()" for more information.

        Otherwise, typing a python command will be executed immediately, with any result printed to the minicom terminal.

          For example, typing:
              >>> print('this')
          indeed will print:
              this

        ---------------------------------------------