Raspberry Pi Pico Play sounds using Circuitpy

I found out that there are two main ways of using Python on a Raspberry Pi Pico, MicroPython or CircuitPython.

It is much harder to play a .wav file on a Pico with MicroPython, and I could not find a solution to play MP3 files with MicroPython.  

There are how every serveral simple tutorials with libraries that exist for CircuitPython.  CircuitPython libraries have better support for sensors but you may want to use MicroPython for: Advanced APIs such as interrupts and threading, or existing MicroPython code.

As of now CircuitPython does support the Wifi on the Pico W so I really could not see any reason not to go for it.  According to CircuitPython documentation it is supposed to be simpler to get started with than MicroPython but I did not find it to be so.  For me using MicroPython with Thonny was super easy to get started with.

I tried to get Thonny to work with CircuitPython but finally gave up and started using the Mu Editor with it.

Installing CircuitPython on the Pico

Install CircuitPython by going to: https://circuitpython.org/downloads and downloading the correct version for your Pico either with our without WiFi.

It is cool that CircuitPython then mounts the Pico as a USB drive that you can interact with. But it took me some time to figure out how to see output from the Pico. 

Use the following command to see what serial interface the Pico is on 

$ ls /dev/ttyACM*

Then connect to it with the screen command

$ screen /dev/ttyACM0 115200

Installing Mu

Download Mu from https://codewith.mu.

When you start Mu the first time you will be prompted to select your 'mode', for now select CircuitPython!

I cannot figure out how to run the program code in the current editor window with Mu like I can Thonny.  If you hit the Serial button it does open the serial pane so you can see the output from the Pico and you can use CNTL-C to enter REPL (Run-Exec-Print_loop), or you can type CNTL-D to execute the program file saved on the Pico as code.py.


Installing CircuitPy in VSCode


This extension aspires to bring your entire CircuitPython workflow into a single place in VSCode.

Getting Started

The extension will currently activate when any of the following occur:

  • workspace contains
    • /code.py
    • /code.txt
    • /main.py
    • /main.txt
    • /boot_out.txt
  • command run  (CNTL-SHIFT-P)
    • circuitpython.openSerialMonitor
    • circuitpython.selectSerialPort
    • circuitpython.closeSerialMonitor