Skip to main content

Set Up the Development Environment

The goal of this page is to get the CoCube MicroPython environment working end to end: the device should connect, flash correctly, show >>>, and run a one-line test.

Completion criteria

When you finish this page, you should be able to:

  • install Thonny on your computer
  • flash the matching MicroPython firmware onto CoCube
  • connect to CoCube from Thonny and see >>> in the Shell
  • run a one-line test successfully

Materials you need

1. Understand the workflow first

For CoCube, you can think of the development flow as two layers:

  1. First flash the MicroPython firmware onto CoCube
  2. Then use Thonny to upload .py files to CoCube and run them

This page focuses on the first layer and the most basic connection check.
The next page covers file management, script execution, and main.py in more detail.

2. Install Thonny

Thonny is the default development tool used throughout this tutorial.
The screenshots, file workflow, and Shell examples later on all assume Thonny.

Note

It is best to prepare both Thonny and the firmware file before you start connecting, flashing, and verifying the device.

2.1 Download and install

Go to the Thonny website to download and install it.

Download Thonny

3. Flash the MicroPython firmware

CoCube needs the correct MicroPython firmware before the connection, upload, and run flow becomes stable. The two common methods are kept below.

Note

This is the most reliable method. You use the local course firmware file directly instead of depending on Thonny to fetch a default firmware online.

  1. Prepare the firmware: Download the matching CoCube firmware file first: Download the CoCube MicroPython firmware.

  2. Connect CoCube: Hold the bottom power button to turn CoCube on, then connect it to the computer with a USB cable.

  3. Configure the interpreter: Open Thonny, click the interpreter status field in the lower-right corner, then choose Configure interpreter.

    Configure the interpreter

  4. Open the flashing tool: In the popup, choose the MicroPython(ESP32) interpreter and the device port, then click Install or update MicroPython (esptool).

    Open the firmware flashing tool

  5. Select the local firmware: In the Install MicroPython (esptool) window, click the button in the lower-right corner, then click Select local MicroPython image and choose the CoCube firmware file.

    Select the local firmware file

  6. Start flashing: Click Install and wait for erase and write to finish until you see Done!.

    Click Install

    Flashing finished

4. Verify the environment

After flashing, it is best to verify the environment immediately.

  1. Reconnect CoCube: Unplug and reconnect CoCube, then confirm that Thonny is still set to the correct port and the MicroPython (ESP32) interpreter in the lower-right corner.

    Important

    The device port may change after flashing. If the connection fails, reselect the port first.

    Reselect the port

  2. Restart the interpreter: If the Shell at the bottom is not responding, click the red stop button in the toolbar to restart the interpreter.

    Restart the interpreter

  3. Check the REPL prompt: If you see version info and >>> in the Shell, CoCube has entered the MicroPython REPL successfully.

    Check the REPL prompt

  4. Run a test line: Enter a one-line test after >>>.

    print("Hello, CoCube!")

    Run a test line

    If the terminal prints the output correctly, the development environment is ready.

If you can reliably see >>> and print the test output, the goal of this page has been met.

5. What next?

The recommended next page is Basic Concepts.
That page connects the most common development actions into one flow: viewing files, using the REPL, running scripts, saving to the device, and understanding main.py.