Skip to content

Running the robot with MicroPython

Thomas Euler edited this page Feb 13, 2022 · 14 revisions

MicroPython

MicroPython is an implementation of Python for microcontrollers, initiated by Damien George and further developed by a very active group around him. The documentation is excellent and there are tons of websites, tutorials etc. on the web, which is why I say here no more.

Flashing the MicroPython firmware

Official builds for all microcontrollers for which a MicroPython port is available, can be downloaded here. There are also firmware versions for different boards with the Raspberry Pi Pico (RM2040) chip.

Important: If a display such as Pimoroni's Pico Display Pack is to be used, then an extended firmware is required: Pimoroni maintains in their Pico repository a fork of MicroPython that supports their gadgets in their repository, from where the latest firmware can be downloaded.

If the Pico already contains UF2 bootloader, which is usually the case, flashing the firmware is easy. To get the board in bootloader mode ready for the firmware update, execute machine.bootloader() at the MicroPython REPL. Alternatively, hold down the BOOTSEL button while plugging the board into USB. The .uf2 file downloaded from the aforementioned repository should then be copied to the USB mass storage device that appears. Once programming of the new firmware is complete the device will automatically reset and be ready for use.

Some hints:

  • Before loading a new firmeware onto a microcontroller, it can be useful to first "nuke" the controller, meaning to reset the flash completely.

    Note that this also deletes all files on in the flash! Before updating, always make sure that you have a backup of your code!

  • How to build the MicroPython firmware, is explained here.

Uploading the code

Use your favorite MicroPython IDE to upload the MicroPython code. A relatively simple but very useful IDE is Thonny, which works out-of-the-box. Alternatively, Atom offers a plugin called pymakr to interact with MicroPython on a microcontroller, but for some reasons it currently (February 2022) does not work well with together with the Pico.

Home

  1. Werkzeuge und Material (DE | EN)
  2. Aufbau
    2.1 Mechanik (DE | EN)
    2.2 Aufbau und Hinweise (DE | EN)
    2.3 Elektronik und Platine (DE | EN)
  3. Sensoren (DE | EN)
  4. Demo (DE | EN)
  5. Erweiterungen & Modifikationen
    5.1 Alternatives Display (DE | EN)
    5.2 CO2-Wächter (DE | EN)
  6. Galerie (DE | EN)
  7. Software - MMBasic
    7.1 MMBasic zum Laufen bringen (DE | EN)
    7.2 Kommentare zum Programm (DE | EN)
    7.3 Robotling API (DE | EN)
    7.4 Building PicoMite MMBasic (DE | EN)
  8. Software - MicroPython
    8.1 Running MicroPython (DE | EN)
    8.2 Building MicroPython (DE | EN)
Clone this wiki locally