• #MicroPython: Visual Studio Code as IDE

    27
    Dec - 2018

    MicroPython | 2 min | 338

    #MicroPython: Visual Studio Code as IDE

    2 min read
    atom
    esp32
    esp8266
    micropython
    visual studio code
    wipy

    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).

    Configuration

    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!

    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).


    Comments

    Empty