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 simple.py
def oof1():
print("oof")
def multiply(a,b):
return a*b
lets create the main file in which we will call the simple module. Name the file as main.py and place in the same directory as simple.py
import simple
simple.oof1()
mul = simple.multiply(22,24)
print(mul)
Installing the Custom Module
In thonny menu bar go to View -> Files. A side bar will appear in thonny window.
![](https://www.dailyduino.com/wp-content/uploads/2021/09/1.png)
Navigate to your directory in which you have saved the simple.py and main.py files. Right click on the simple.py file and click “Upload to /”
![](https://www.dailyduino.com/wp-content/uploads/2021/09/2.png)
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
![](https://www.dailyduino.com/wp-content/uploads/2021/09/3.png)
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
![](https://www.dailyduino.com/wp-content/uploads/2021/09/4-1.png)
If you execute the main.py file you will see the following output
![](https://www.dailyduino.com/wp-content/uploads/2021/09/5.png)
Cool ! now you have successfully installed and tested custom micropython module