If you are new new in python/micropython programming, this tutorial guide is for you. It will help you in getting start with python/micropython with thonny IDE, and here we will also discuss about basics of CircuitPyhton for specific applications.
For installing Thonny IDE in your system, first you have to download the its application according to your operating system. For this please click on below link
https://thonny.org/ . Once you open this page you will see a small grey box like this:
After locating the gray box click on appropriate link for your operating system, and install it after downloading the application.
Now open it and lets discuss about user interface of it. Let’s make sure you understand what Thonny has to offer. Think of Thonny as the workroom in which you will create amazing Python projects. Your workroom contains a toolbox containing many tools that will enable you to be a rock star Pythonista. In this section, you’ll learn about each of the features of the UI that’ll help you use each of the tools in your Thonny toolbox.
Code Editor and Shell
After open it you will see a window with several icons at the top and two blank area. The Top section is the Code Editor area where you will write every code and the bottom area is Shell where you will get output of your code as well as error message (If occurs in your).
Across the top you will see the several icons, these are the tools that will be used during working with this IDE. So, let’s discuss about these tools.
A This icon is for creating new python file, you can also activate this tool from your keyboard by pressing Ctrl+N.
B File Icon, this icon is use to open any python file already created in your system, or If you connected any Micropython board you can also open file if any file already saved in it.
C For saving current working file
D Run Icon, used to compile/run the current scrip (or code
E The bug icon allows you to debug your code. It’s inevitable that you will encounter bugs when you’re writing code. A bug is another word for a problem. Bugs can come in many forms, sometimes appearing when you use inappropriate syntax and sometimes when your logic is incorrect.
F-H. The arrow icons allow you to run your programs step by step. This can be very useful when you’re debugging or, in other words, trying to find those nasty bugs in your code. These icons are used after you press the bug icon.
I Resum Icon, allows you to return to play mode from debug mode.
J Stop/Restart Icon is used to Stop the current running code. This is very useful when working with micrpython devices for connecting and reconnecting to your system.
Uploading Micropython Firmware
- Hold Boot Button and plug-in in your computer system via USB cable after that release Boot button, you will get a pop-up window of showing RaspberryPi as a mass storage device. Copy the downloaded firmware file(firmware.uf2) and paste it in the raspberry pi board or you can also do this by simply drag and drop method. Now, your board has updated firmware in it.
Setup Board for micropython
- After uploading micropython firmware to your board. Now connect your board to pc via USB cable .
- Open Thonny IDE and Choose interpreter as MicroPython (Raspberry Pi Pico).
Installing CircuitPython Firmware
For using circuit python in your board you have to update the firmware of it and upload the circuitpython firmware(i.e,adafruit-circuitpython-raspberry_pi_pico-en_US-7.1.1.uf2). For this first you need to press the boot button then connect the USB, don,t release the button until you connect the USB to the laptop. then you see a new device named "RPI-RP2" drag the firmware file. "adafruit-circuitpython-raspberry_pi_pico-en_US-7.1.1.uf2" to your device as shown in figure: You can also download circuitpython firmware from its official website (link is below) https://circuitpython.org/board/raspberry_pi_pico/
When you properly insert the circuit python then you see a new device that looks like the below image:
After this go to run->select interpreter,choose device and port