Getting started with CircuitPython¶
This section of the documentation takes you through getting up and running with CircuitPython on iMX RT1011 Nano Kit.
Requirements¶
Before you start, check that you have the required hardware and software:
- 1x iMX RT1011 Nano Kit
- 1x USB-C Cable
- A computer running macOS, Linux, or Windows 7 or newer
Ensure UF2 Bootloader is present
CircuitPython requires the UF2 Bootloader running on the board. If the UF2 Bootloader is not present or gets corrupted somehow, you can re-install the UF2 Bootloader by following the UF2 Bootloader Installation section.
Installing CircuitPython¶
The pre-built CircuitPython firmware in .uf2
-format is located in firmware/circuitpython/
.
Download the latest firmware and complete the following steps to flash the firmware:
- Plug your board into the USB port of your computer.
- Double-click the RST/BT button to enter UF2 Bootloader mode.
- The board will mount as a Mass Storage Device called UF2BOOT and the Red LED blinks slow.
- Drag and drop
circuitpython-imxrt1011_nanokit-en_US-<version>.uf2
onto the UF2BOOT volume. The Red LED blinks fast during flashing. - CircuitPython will start running after flashing. It will mount as a Mass Storage Device called CIRCUITPY.
Coding with Mu Editor¶
Mu Editor is a simple Python code editor for beginner programmers. Go to Mu Editor Download page, choose your operating system and follow the instructions to install the latest Mu Editor.
Start Mu Editor, click Mode on Top Menu. You will be prompted to Select Mode. Select CircuitPython and click OK.
In the text editor, try some Python code:
Click Save on Top Menu. A window will appear. Give the name code.py
for your code and save it onto the CIRCUITPY drive. Your code will run as soon as the file is done saving.
Click Serial on Top Menu to open a serial data connection to the board. This will result in a new pane between the text editor and Mu’s footer, which prints the data from the board.
Using CircuitPython REPL¶
The CircuitPython REPL (Read-Evaluate-Print-Loop) allows you to enter individual lines of code and have them run immediately. It's really handy if you're running into trouble with a particular program and can't figure out why. It's interactive so it's great for testing new ideas.
To use the REPL, you first need to be connected to the serial console. Here are the common ways you can use to establish a serial connection:
Mu Editor has a Serial Console, which can be used to interact with CircuitPython REPL.
Click Serial on the Mu Editor's Top Menu to open a serial data connection to the board. This will result in a new pane between the text editor and Mu’s footer:
On macOS/Linux, you can open up a terminal and run:
Where <serial-port-name>
is the correct serial port that your computer uses to communicate with the board.
On Windows, you can use PuTTY to interact with CircuitPython REPL.
Start PuTTY, configure the correct serial port and click Open:
Where <serial-port-name>
is the correct serial port that your computer uses to communicate with the board.
Once that connection has been established, type CTRL + C to drop into the REPL.
Try to write some Python code in the REPL, then press Enter :
Return to the Serial Console
When you're ready to leave the REPL and return to the serial console, simply press CTRL + D . This will reload your board and reenter the serial console. You will restart the program you had running before entering the REPL.