Getting Started with Raspberry Pi Pico W and CircuitPython

Getting Started with Raspberry Pi Pico W and CircuitPython

If you're looking for a low-cost, high-performance microcontroller board that features built-in WiFi connectivity, the Raspberry Pi Pico W might be just what you need. In this tutorial, we'll walk you through the basics of setting up your Pico W board, installing CircuitPython, and writing your first program using CircuitPython.

 

Video Tutorial


 

Overview of the Pico W Board

The Raspberry Pi Pico W board is a microcontroller board that's based on the RP2040 chip. It features built-in WiFi connectivity, and it has 26 GPIO pins that can be used for a variety of projects. The board also has a micro USB port for power and data transfer.

 

Prerequisites

To follow this tutorial, you will need the following:

  • A Raspberry Pi Pico W board
  • A computer with the CircuitPython Thonny editor and a USB cable for connecting to the Raspberry Pi Pico W
  • Basic knowledge of the Python programming language

Hardware Components

Raspberry Pi Pico Wireless Out Of Stock
x 1 unit(s)

 

Setting up the Hardware

To begin, we need to set up the Raspberry Pi Pico W board. Here are the steps to follow:

  1. Connect the Raspberry Pi Pico W board to your computer using a USB cable.
  2. Make sure the board is in bootloader mode by pressing and holding the "BOOTSEL" button while connecting the USB cable.
  3. Once the board is in bootloader mode, it should appear as a USB drive on your computer.
  4. Download the latest version of the CircuitPython firmware (.uf2 file) from the official website (https://circuitpython.org/board/raspberry_pi_pico_w/).
  5. Copy the CircuitPython firmware file onto the USB drive of the Raspberry Pi Pico W.

After you have copied the CircuitPython firmware file onto the Pico W board, the board will reboot and you should see a new drive called "CIRCUITPY" on your computer. This is where you can save your CircuitPython code files and any other data files that your code needs to access.

The "CIRCUITPY" drive will initially contain a few files and folders that are needed for CircuitPython to run on the board, including:

  • code.py - This is the default CircuitPython code file that is automatically executed when the board is powered on or reset. You can edit this file or create new files to write your own CircuitPython programs.
  • lib - This folder contains any libraries or modules that your CircuitPython code needs to use.

Once the firmware is installed, the Raspberry Pi Pico W board is ready to use with CircuitPython.

 

Installing Thonny Editor

To write and run CircuitPython programs, we will use the Thonny editor. Here's how to download and install it:

  1. Go to the official Thonny website (https://thonny.org/).
  2. Click on the "Download" button in the top menu.
  3. Select the version of Thonny that matches your operating system (Windows, Mac, or Linux).
  4. Once the download is complete, install Thonny on your computer by running the installation file and following the instructions provided.

Thonny is a popular Python editor that supports CircuitPython and is easy to use for beginners. Once you have installed Thonny, you can connect your Pico W board to your computer and start writing and running CircuitPython code.

 

SetupThonny Editor

  1. Open Thonny Editor and click on "Run" and then "Select Interpreter" from the top menu.

  2. From the dropdown menu, select "CircuitPython".

  3. Make sure to let Thonny detect the port automatically by selecting "Auto".


     

  4. Click on "View" and then click on "Files".



     

  5. Click on the "Stop" button next to the "Run" button at the top of the window.

  6. The files on the Pico's CIRCUITPY drive should now be visible in the "Files" pane. Double-click on code.py to open it in the editor.



     

Writing the CircuitPython Program

Now that we have the hardware set up and the Thonny editor installed, let's write a simple CircuitPython program to blink the onboard LED. Here's the code:

This code imports the necessary libraries, sets up a digital output pin for the built-in LED, and then runs an infinite loop that turns the LED on and off with a half-second delay between each state change.

 

Running the CircuitPython Program

  1. Save the CircuitPython program code then click on the green button "Run"


     

  2. Wait for the program file to finish copying onto the Raspberry Pi Pico W board.

  3. The onboard LED should now start blinking according to the program.

 

Conclusion

In this tutorial, we learned how to set up the Raspberry Pi Pico W board for use with CircuitPython, how to install the Thonny editor, and how to write a simple CircuitPython program to blink the onboard LED. We also went through the steps to run the program on the Raspberry Pi Pico board. With this knowledge, you can now begin exploring the world of CircuitPython and start building your own project


Related Posts

Build a Traffic Light Project with Pico W and CircuitPython

Build a Traffic Light Project with Pico W and CircuitPython

Want to learn how to build a traffic light project using Pico W and CircuitPython? In this tutorial, we'll show you how to create a functional traffic light with just three LEDs and two buttons..