Using the Pymakr Extension in VSCode

pymaker

  1. install pymakr preview

    code --install-extension Pycom.pymakr-preview
    

Getting Started with Pymakr (from here)

  1. In File explorer(ctrl+shift+e)
    1. add or create a project folder for holding your micropython code (suggestion: name it “micropython”). Consider creating one in your “code” git repository.
  2. navigate to “Pymakr: Projects” tab in the workspace explorer window on the left
    1. select “create project”. Select the same code folder as above and specify a project name (like “hello-world”). Select the option to create a subdirectory with the micropython folder.

      Define the name
      Define the name

      create the project in a subfolder
      create the project in a subfolder

      specify empty project
      specify empty project

    2. Connect your device via usb to your computer

    3. Within the “hello-world” project that is created within the “Pymakr: Projects” tab, add a new device. Follow the prompts to select the appropriate com port

      Select your device
      Select your device

    4. Connect to the device by selecting the lightning bolt icon

      Connect to Device
      Connect to Device

    5. Open up a terminal window by selecting the box with an arrow in it

      Open up a Terminal Window
      Open up a Terminal Window

    6. A terminal window should open and look like this:

      Example of terminal window
      Example of terminal window

      MicroPython v1.19.1 on 2022-06-18; ESP32 module with ESP32
      Type "help()" for more information.
      >>>
      
    7. At the command prompt, type in

      print('hello world')
      

      which should return

      hello world
      
    8. If you wish to disconnect, you can use:

      Figure
      Figure

Working with Micropython

Micropython can either run code from the interpreter (the “terminal” as VSCode puts it), or by loading a file from its onboard storage. When the ESP32 is reset (using the EN button), it looks for two files, in a specific order:

  1. boot.py
  2. main.py

if there are any loops in these files that prevent execution from ending, you must type ctrl+c to terminate execution from the interpreter window. This will stop any python files from running and bring control back to the interpreter

You must always stop execution on the ESP32 before trying to upload files to it.

Saving files to/from the ESP32

Within the “Pymakr: Projects” workspace there are several other buttons that you can use to sync files to the esp32

  • Upload project to device: Uploads all your project files to the device
  • Download project from device: Pulls files off the device
  • Open in Explorer: This opens up the ESP32 as a virtual file system in the file explorer and allows you to investigate and work with the file system directly.

From the file explorer window, you can also right click and select “pymakr–>upload to device” to upload individual files

External Resources