microPython IDEs for SBC

if you want to write your own software…

An IDE (Integrated Development Environment) is a software application that facilitates the programming task.
The SBC is compatible with any IDE that supports microPython.
In this section we want to introduce some of the IDEs that our engineers use on a daily basis to program the SBC:

Generic Notepad

Not much to say here :)
This is the simplest way to edit your code. You can use your preferred Notepad application, although Notepad++ is a nice one since it highlight Python syntaxis.

We use this editor to make quick changes to existing code that does not need much testing.

../_images/notepadpp.png

Thonny

Thonny is a Python and microPython IDE.
We like it because it is free, multiplatform, light and easy to use.

In this quick tutorial we will only cover the basics, you can find more information on their website.

  1. Connect your SBC to your PC via USB

  2. Run Thonny

  3. Go to Tools > Options > Interpreter

    Select MicroPython (generic) as interpreter
    Select your SBC Port
    Click OK

    ../_images/Thonny_cfg.png
  4. Press the STOP button

    ../_images/Thonny_stop.png
  5. If everything went ok, you should see a similar message in the shell which indicates that you connected successfully to the SBC microPython terminal.

    ../_images/Thonny_welcome.png

6. You can now write your application in the main window and click the Play button to run it.
You will see your application output in the shell (window at the bottom).

Notice that you can also write commands directly in the shell.

../_images/Thonny_test.png

Terminal

You can run or code any Python application directly from a terminal (Putty, Realterm, …).

We will make a quick tutorial explaining how to connect to your SBC via Putty.

  • Configuration

    Choose Connection type: Serial, desired COMx port and Speed as 115200, click Open.
    If you don’t know your SBC COM port, you can use Windows device manager.

../_images/putty_config.png
  • Welcome

    If the connection is succesfull, SBC will show a welcome message and the microPython prompt “>>>”

../_images/putty_welcome.png
  • Write your code

    • REPL

      REPL means “Read Eval Print Loop” and it is a native feature of python and micropython.
      Here the user can develop scripts line by line, define functions or examine variables.

      Just write a line of code and hit enter to execute it.

    ../_images/putty_REPL.png
    • Paste mode

      For more complex scripts, micropython supports paste mode. This mode allows paste longer scritps to the REPL.
      To enter paste mode, press CRTL+D in a BLANK LINE. Micropython should change promt to “===”.
      Now you can paste your scritps. Remember that Putty uses mouse right click as paste command.
      Press CTRL-E to exit from the paste mode and execute your script.

Jupyter

Before start with jupyter notebooks, you can read the basic guide here: Notebook Basics.

  • New notebook

    The first step is to add a new notebook, for that you need to press new notebook button and select Micropython-USB kernel.

../_images/jupyter_new_notebook.png
  • Insert cell

    Cells are small scripts that can be executed in micropython. Press “+” button to add new cells

../_images/jupyter_insert_cell.png
  • Run cell

    To tun cells, select cell and press “RUN” button

../_images/jupyter_run_cell.png
  • Serial connect

    Before executing any sript in micropython, the user should connect to the SBC. To do so, run a cell with %serialconnect command.

../_images/jupyter_run_cell.png
  • Rename

    Click the notebook title to rename it

../_images/jupyter_rename.png
  • Download

    When your script is done, you can save it as a Jupyter notebook (.pynb) or download it as an .html file

../_images/jupyter_download.png