Interfacing with Micropython on the Raspberry Pi Pico
Contents
Interfacing with Micropython on the Raspberry Pi Pico#
Raspberry Pi Pico#
Comaptible Hardware#
Development Environments#
There are two Micropython development environments that are particularly useful with the Raspberry Pi Pico.
Thonny IDE#
The Thonny IDE is the most widely used IDE for Micropython and should be part of any installation. It is mature, fully supported, and does nice things like setting the real time clock on reboots.
Jupyter notebooks#
Jupyter notebooks are an excellent means of combining narrative, code, and results in a single document. Jupyter kernals for Micropython are being developed by a number of users on github, but not yet in a mature state.
Jupyter MicroPython Kernel Follow the instructions to install from PyPi using
pip3
. See MicroPython on ESP Using Jupyter Notebook for more detail.jupyter-micropython-upydevice More recent, but so far not working with Raspberry Pi Pico
Activity#
If you haven’t already done so, install the Anaconda distribution of Python on your laptop.
Install the Jupyter Micropython kernal on your laptop.
Attach your Raspberry Pi Pico, then test your kernal by running the following two code cells. Be sure to specify the MicroPython-USB kernal.
%serialconnect
Found serial ports: /dev/cu.usbmodem143101, /dev/cu.BLTH, /dev/cu.Bluetooth-Incoming-Port
Connecting to --port=/dev/cu.usbmodem143101 --baud=115200
Ready.
import machine
import time
led = machine.Pin(25, machine.Pin.OUT)
start = time.time()
while time.time() - start <= 20:
led.toggle()
time.sleep_ms(500)
....