A Handy MicroPython Development Tool.

abby06

Abby

Posted on August 12, 2020

A Handy MicroPython Development Tool.

Introduction

RT-Thread open-source Internet of Things operating system provides MicroPython Developers with an excellent development environment that helps them to get started IoT OS quickly.

RT-Thread MicroPython is plug-in in VScode, which provides a powerful development environment for MicroPython development. The main features are as follows:

  • The convenient connection mode of development board (serial port, network, USB)
  • Support MicroPython-based code intelligent completion and syntax check
  • Support MicroPython REPL interactive environment
  • Provides many code samples and demo program
  • Support full project synchronization function
  • Support to download files or folders to the development board
  • Supports fast running code files in memory
  • Supports code snippets to run functions
  • Supports several major MicroPython development boards
  • Support Windows and Ubuntu operating systems
  • Development board support list

Preparation

1- Using plug-in under the Windows operating system requires changing the default terminal of VScode to Powershell, as shown below:

1.gif

If you want to use the MicroPython autocompletion feature (you can skip the next step if you don't need autocompletion for now), you need to do the following:

2- Install the Python plug-in

3- Install Python3 on your PC and add it to the system environment variables as instructed by the Python plug-in

99.png

If you already have the above plug-ins and programs installed on your PC, you can skip this preparation step.

Ubuntu support

This plug-in supports running under ubuntu 18.04. In order to avoid frequent access to serial port permissions under the ubuntu system, the current user needs to be added to the user group dialout. Manually enter the following command: $USERNAME is the current USERNAME of the system:

sudo usermod -ag dialout $USERNAME

Note: the configuration change requires to restart the operating system for the configuration to take effect.

Mac support

RT-Thread MicroPython plug-in supports Mac 10.15 Catalina OS.

Quick Start

Create a MicroPython project

The first step in MicroPython development is to create a MicroPython project within which all subsequent operations must run. There are two ways to create a new MicroPython project, a blank project and a demo-based project, which are shown below.

2.gif

Connecting development board

You can connect to the MicroPython development board by clicking the connection button in the lower-left corner and then selecting the device you want to connect to in the pop-up list of devices.

3.gif

View the sample code file

The MicroPython plug-in provides a wealth of sample code and library files to view in the left active bar. Right-click on the sample file to add the sample file to the project from the drop-down menu.

88.png

Run MicroPython files directly on the development board (kind for debug)

This feature is used to quickly debug a single file and is frequently used in debugging code. When we write the test program in a separate file, we can use this function to download the current python file to the memory of the development board to run, achieving the effect of rapid debugging. We can also use the shortcut key Alt + q to trigger this function.

4.gif

Run MicroPython code snippets on the development board

If you just want to debug a small amount of code without downloading files to the development board, you can use the code snippet function. You can run the selected code in the REPL environment by selecting the snippet you want to run in the editor, and then selecting the execute the selected MicroPython code option on the device from the right-click menu.

5.gif

Download files/folders to the development board

If you want to download individual files/folders to the development board, you can use the function of to download individual files/folders to the development board. Select the file/folder in the project that you want to download to the development board and use this feature in the drop-down menu.

Note that if there are files/folders with the same name on the development board, the download will overwrite the existing files/folders.

By entering the command os.listdir() in repl, you can check whether the corresponding file/folder has been downloaded successfully. Similarly, you can also use the corresponding command to delete the file or folder in repl. The command list is as follows:

0E9D902D-7B24-4db0-8261-6EC64F90E1C3.png

6.gif

Project synchronization

Click the synchronization button in the lower left corner to start the project synchronization function. This feature synchronizes all directory files in the local project to the development board's file system. This feature is recommended to be used after the code is debugged, without the need to synchronize the project frequently during debugging.

After the project synchronization is completed, the list of files in the DEVICE can be seen in the DEVICE FILES LIST column.

7.gif

Intelligent code completion based on MicroPython

This plug-in supports intelligent code completion and syntax checking based on MicroPython syntax, which is a powerful tool for developing MicroPython code. It allows developers to write functions while looking at API parameter hints, and it gives them a visual reminder that makes it easier to find errors in code.

For more information about RT-Thread Micropython, please reach RT-Thread Github .

About RT-Thread:

An open-source embedded real-time operating system born in 2006 that provides developers with a wide range of components and 200+ software packages.

RT-Thread Contact Info:

Website | Github | Twitter | Facebook | Youtube

💖 💪 🙅 🚩
abby06
Abby

Posted on August 12, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related