Develop Your First Python Script

Write Your First Script File

Create a helloworld.py file to output "hello world". The script is as follows:

print("hello world")

Use QPYcom to download the edited file above to the module and run the file.

Transfer Files Between PC and Module

Download Method 1:

image-2021081301
  • Step1: Open the Serial Port

Set "COM Port" to the module's interaction port and click "Open port".

  • Step2: Download via the Tool's Button

Click the "File" tab and upload or delete files by clicking "+" or "-" on the right side of the page.

  • Step3: Download via Drag and Drop

You can also drag and drop the local files (or folders) displayed on the left side of the page to the module on the right.

  • Step4: Download Progress and Result

The name of the downloaded file and the download progress will be displayed in the status bar.

Download Method 2:

image-2021081301
  • Step1: Create a Project

Click "Create" to create a project according to your needs and execute the steps in "Download Firmware".

  • Step2: Configure the Files to Download

Select the script to be downloaded to the module (Right click the script file in the "User scripts/files" section).

  • Step3: Configure Download Mode

Click "▼" on the right side of "Download script" and select "Download script" in the drop-down list.

  • Step4: Download the Script

Click "Download script" to start downloading the script. The download progress percentage will be displayed on the progress bar.

Run Script

  • Step1: Download the Script

Download the script file to be run in the module.

  • Step2: Execute the Script via REPL

After opening the port, enter the following codes on the QPYcom "REPL" page to run the script file.

import example
example.exec("/usr/helloworld.py") # The file path is the path of the script file to be run.
  • Step 3: Execute the Script via GUI Tool

Or select the script file and click "" on the "File" page to run the script.

The execution result is as follows:

Stop a Running Program

Depending on the type of running script file, there are the following methods to stop it:

Program
name is "main.py"
Program
Contains Endless Loop
Program
Uses Multithreading
Stop Steps
1. Press "Ctrl + A" to enter RAW mode
2. Press "Ctrl + D" to restart the QuecPython virtual machine
3. Press "Ctrl + B" to return to normal interaction mode
4. If the above methods are ineffective, please re-download the firmware
1. Press "Ctrl + C" to interrupt the program execution
2. If the above method is ineffective, please re-download the firmware
1. Press "Ctrl + A" to enter RAW mode
2. Press "Ctrl + D" to restart the QuecPython virtual machine
3. Press "Ctrl + B" to return to normal interaction mode
4. If the above methods are ineffective, please wait patiently for the program to finish running
1. Press "Ctrl + C" to interrupt the program execution
2. If the above method is ineffective, please re-download the firmware
1. Press "Ctrl + D" to restart the QuecPython virtual machine
2. If the above method is ineffective, please reboot the module
1. Press "Ctrl + D" to restart the QuecPython virtual machine
2. If the above method is ineffective, please reboot the module
1. Press "Ctrl + C" to interrupt the program execution
2. If the above method is ineffective, please re-download the firmware or reboot the module
1. Press "Ctrl + C" to interrupt the program execution
2. If the above method is ineffective, please re-download the firmware or reboot the module