• 27
    Dec - 2018

    2 min | 889

    #MicroPython: Visual Studio Code as IDE

    MicroPython | 2 min | 889

    visual studio code
    wipy 3.0

    Quoting the official MicroPython's website:

    MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimised to run on microcontrollers and in constrained environments.

    Besides C++ and C, I use MicroPython to program microcontrollers, especially the ESP32/ESP8266 types. These two microcontrollers are compatible with MicroPython and it is easy to integrate sensors and actors programming using this language. I wrote a tutorial about installing MicroPython on the ESPs, as well a lot of articles about these microcontrollers and MicroPython. This is an update to the "Getting started with MicroPython": I am changing from Atom to Visual Studio Code (VSCode), and using the PyMakr extension, it is possible to program and debug MicroPython on VSCode.

    Visual Studio Code

    The open-source VSCode is a code editor redefined and optimized for building and debugging applications. It is compatible with Windows, Linux and Mac OS X.

    “The majority of Google developers are using it now,” Chris Capossela, Microsoft’s chief marketing officer, said on the Windows Weekly podcast. :)

    Visual Studio Code - Pymakr extension
    Fig. 1: Visual Studio Code - Pymakr extension

    To use VSCode for MicroPython, you need to install the Pymakr extension (see Fig. 1).


    You can configure the plugin using Ctrl+Shift+P and search for Pymakr > Global Settings, you get something like this:

        "address": "COM9",
        "username": "micro",
        "password": "python",
        "sync_folder": "",
        "open_on_start": true,
        "safe_boot_on_upload": false,
        "sync_file_types": "py,txt,log,json,xml,html,js,css,mpy",
        "ctrl_c_on_connect": false,
        "sync_all_file_types": false,
        "auto_connect": false

    That is the global configuration. If you want to have a local configuration you need to create a file called pymakr.conf inside the folder of the project with the content from above.

    I had some issues with connecting the WiPy 3.0 (pycom). With all the other ESP boards, VSCode works really good. But with the WiPy, it was difficult to connect, and I got usually an error, when I tried to upload the files! :( I was not able to enable the safe booting because I did not find the option! If you have some tips, write them on the comment section!
    The safe booting option can be enabled with this option: "safe_boot_on_upload": true.
    The new plugin version includes an auto connect option set to true. You need to disable it on the settings "auto_connect": false, if your board is not found. I have some issues with this option.


    The PyMakr requires Node.js. Instructions to install it are available here. For Ubuntu users to install the lastest LTS version, you can use the following lines

    sudo apt-get install curl python-software-properties
    curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
    sudo apt-get install nodejs

    MicroPython IDE for VSCode

    There is also another extension for MicroPython: MicroPython IDE for VSCode. This allows to flash the firmware using the esptool.py, but it works on Linux, but not on Windows (esptool.py is not an executable on Windows).