In this tutorial you can see how to create a custom micropython module and install it to your raspberry pi pico (RP2040) using Thonny

Coding the Custom Module

Let’s create a simple module with two functions and name the file as

def oof1():

def multiply(a,b):
	return a*b

lets create the main file in which we will call the simple module. Name the file as and place in the same directory as

import simple


mul = simple.multiply(22,24)

Installing the Custom Module

In thonny menu bar go to View -> Files. A side bar will appear in thonny window.

Navigate to your directory in which you have saved the and files. Right click on the file and click “Upload to /”

after clicking the “Upload to /” button the module should be uploaded to the Pi Pico and should show the file under the Raspberry Pi Pico sidebar

Now you have successfully installed the custom module to your pi pico.

Testing the Custom Module

We can import the module using the following code.

import simple

and if we call the function from the module we should see the output

If you execute the file you will see the following output

Cool ! now you have successfully installed and tested custom micropython module

If you like our content, please consider buying us a coffee.
Thank you for your support!