Raspberry Pi Pico: What you should know and How to get started?

Raspberry Pi Pico: What you should know and How to get started?

0 comments / Posted on by Harsh Sehgal

Raspberry Pi Pico: What you should know and How to get started?

Raspberry Pi took the maker market by wonder when they released their first single board computer in 2012. It wasn't like anything anyone had seen before. It was a credit card sized, fully capable Linux computer that retailed for only INR 2.5k (35 dollars). It was groundbreaking! Since then, they have released many other like boards the Pi 2, the Pi 3 with Wi-Fi and BLE, the Pi Zero with a small form factor and the Pi 4 with support for two displays and gigabit Ethernet. However, the Raspberry Pi foundation has blown every development board out of water by launching their very first microcontroller, the Raspberry Pi Pico in January 2021! Not only that but they've built their own silicon called the RP2040 which is used to power this board. Pico is a tiny microcontroller board for just 292 rupees (4 dollars) and this fast, versatile board has a lot more to offer. So, let's unveil the specifications!

 

Let’s see the brain of Pico, the RP2040 chip developed by Raspberry Pi itself.

 

RP2040 Technical Specifications:

  • RP2040 chip features a dual-core Arm Cortex-M0+ processor.
  • 264KB internal RAM and supports up to 16MB of off-chip Flash.
  • Wide range of flexible I/O options: I2C, SPI, and uniquely programmable I/O (PIO).
  • Programmable in C and MicroPython.
  • Has USB 1.1 host.
  • Device has low power sleep and dormant modes.
  • Has drag and drop programming using mass storage over USB
  • Has 26 multi-function GPIO pins
  • Supports a variety of communication protocols including two SPI, two I2C, two UART
  • Has three 12-bit analog to digital converters.
  • Has 16 controllable PWM channels.
  • It has an accurate clock and timer on chip.
  • Has temperature sensor on board.
  • Has accelerated floating point library on chip
  • Has eight programmable IO state machines for custom peripheral support.

 

Raspberry Pi Pico Pinout

This means they can be used for endless possible applications with this small and affordable package. What sets the Pico apart from the crowd is its dual core ARM processor with flexible clock which can go up to 133MHz for such insanely low price with such a powerful microcontroller and high-performance bus matrix such that it can get full performance on both cores concurrently. The programmable I/O (PIO) that has four state machines can be used to handle data, incoming and outgoing, to offload the Pico. This feature is not available in rest of the microcontroller. Hence these other microcontrollers cause timing problems when one is trying to use interrupts to turn the pins ON and OFF directly. Besides, it takes a lot of processing resources that you may need for other things and it’s not the recommended way to use a microcontroller. This problem is circumvented in the Pico making it unique.

 

Raspberry Pi Pinout

Although many projects like Traffic light controller, Reaction game, Burglar alarm, Temperature gauge, Data logger, etc are already being done, this kind of powerful microcontroller implores us to do something bigger like training Machine Learning (ML) models! The powerful Pico comes prepared even for that by being equipped to handle TensorFlow for MicroPython. The Raspberry Pi foundation has continued supporting Python for implementing communication protocols because Python is modular and flexible. This is extended to Pico as well but Python is too resource intensive for such small microcontrollers. Hence, the RP2040 and the Pico can be used with MicroPython which has a subset of all the standard Python libraries and it won’t take up a lot of RAM. Since the syntax of MicroPython is same as Python, it causes no problem for user to code and we can use the plethora of resources for MicorPython to get started!

Raspberry Pi Pico displaying LED blink

  

To start tinkering with Raspberry Pico they’ve released many documents including one that is literally called “Getting started with Raspberry Pi Pico”. Other essential documents are: Raspberry Pi Pico Datasheet, RP2040 Datasheet, Hardware design with RP2040, Pico C/C++ SDK, and Pico Python SDK.

 

Let’s see how to blink an LED to learn about controlling GPIO pins and get started on Pico.

Blinking external LED using GPIO pins of Pi Pico

 

Installation of MicroPython for Raspberry Pi Pico

First, we need to set up our computer/laptop to upload codes to Pico. This can be done in 3 simple steps:

  • Install Thonny IDE
  • Add MicroPython to Pico
  • Upload codes

 To install Thonny, go to “thonny.org”

Thonny IDE

And click on the link to download for your system specification.

Thonny IDE Installation

The installation process is simple and will only take a few seconds.

 

Thonny IDE Window

Now, connect the Pico to the COM port and open Thonny, go to “tools” à “options” à “interpreter” à select “MicroPython (Raspberry Pi Pico)” as the interpreter and select the COM port being used.

 

Installing MicroPython on Raspberry Pi Pico

(NOTE: There’ll be a prompt asking to install MicroPython, click yes (as shown in the figure) and then you can check in shell that Pico is connected.)

Blink LED Circuit using Raspberry Pi Pico

 

Circuit connections for Pico is very simple. Connect the LED in series with 220 ohm or 100 ohm Resistor. Connect the other pin of Resistor to the Ground pin of the Pico. Connect the GPIO 2 pin of Pico to the LED positive terminal. Now the circuit connection is complete.

Blink LED using Pico

 

Code for Blinking LED using Raspberry Pi Pico

The code written is simple. GPIO pins are imported from Machine and a Timer is used to create delay of 1 second.

from machine import Pin, Timer
led = Pin(2, Pin.OUT)
LED_state = True
tim = Timer()
def tick(timer):
global led, LED_state
LED_state = not LED_state
led.value(LED_state)
tim.init(freq=1, mode=Timer.PERIODIC, callback=tick) 
 

It’s a dream come true for many hobbyists to have low power consumption and high-performance applications by RP2040 and Pico. With release of Pico, Raspberry Pi has indeed set new precedence by building their board and silicon! With that they have certainly shaken the microcontroller market. With the power of MicroPython, this little microcontroller is going to cause wonders!

Raspberry Pi took the maker market by wonder when they released their first single board computer in 2012. It wasn't like anything anyone had seen before. It was a credit card sized, fully capable Linux computer that retailed for only INR 2.5k (35 dollars). It was groundbreaking! Since then, they have released many other like boards the Pi 2, the Pi 3 with Wi-Fi and BLE, the Pi Zero with a small form factor and the Pi 4 with support for two displays and gigabit Ethernet. However, the Raspberry Pi foundation has blown every development board out of water by launching their very first microcontroller, the Raspberry Pi Pico in January 2021! Not only that but they've built their own silicon called the RP2040 which is used to power this board. Pico is a tiny microcontroller board for just 292 rupees (4 dollars) and this fast, versatile board has a lot more to offer. So, let's unveil the specifications!

 

Let’s see the brain of Pico, the RP2040 chip developed by Raspberry Pi itself.

 

RP2040 Technical Specifications:

  • RP2040 chip features a dual-core Arm Cortex-M0+ processor.
  • 264KB internal RAM and supports up to 16MB of off-chip Flash.
  • Wide range of flexible I/O options: I2C, SPI, and uniquely programmable I/O (PIO).
  • Programmable in C and MicroPython.
  • Has USB 1.1 host.
  • Device has low power sleep and dormant modes.
  • Has drag and drop programming using mass storage over USB
  • Has 26 multi-function GPIO pins
  • Supports a variety of communication protocols including two SPI, two I2C, two UART
  • Has three 12-bit analog to digital converters.
  • Has 16 controllable PWM channels.
  • It has an accurate clock and timer on chip.
  • Has temperature sensor on board.
  • Has accelerated floating point library on chip
  • Has eight programmable IO state machines for custom peripheral support.

 

Raspberry Pi Pico Pinout

This means they can be used for endless possible applications with this small and affordable package. What sets the Pico apart from the crowd is its dual core ARM processor with flexible clock which can go up to 133MHz for such insanely low price with such a powerful microcontroller and high-performance bus matrix such that it can get full performance on both cores concurrently. The programmable I/O (PIO) that has four state machines can be used to handle data, incoming and outgoing, to offload the Pico. This feature is not available in rest of the microcontroller. Hence these other microcontrollers cause timing problems when one is trying to use interrupts to turn the pins ON and OFF directly. Besides, it takes a lot of processing resources that you may need for other things and it’s not the recommended way to use a microcontroller. This problem is circumvented in the Pico making it unique.

 

Raspberry Pi Pinout

Although many projects like Traffic light controller, Reaction game, Burglar alarm, Temperature gauge, Data logger, etc are already being done, this kind of powerful microcontroller implores us to do something bigger like training Machine Learning (ML) models! The powerful Pico comes prepared even for that by being equipped to handle TensorFlow for MicroPython. The Raspberry Pi foundation has continued supporting Python for implementing communication protocols because Python is modular and flexible. This is extended to Pico as well but Python is too resource intensive for such small microcontrollers. Hence, the RP2040 and the Pico can be used with MicroPython which has a subset of all the standard Python libraries and it won’t take up a lot of RAM. Since the syntax of MicroPython is same as Python, it causes no problem for user to code and we can use the plethora of resources for MicorPython to get started!

Raspberry Pi Pico displaying LED blink

  

To start tinkering with Raspberry Pico they’ve released many documents including one that is literally called “Getting started with Raspberry Pi Pico”. Other essential documents are: Raspberry Pi Pico Datasheet, RP2040 Datasheet, Hardware design with RP2040, Pico C/C++ SDK, and Pico Python SDK.

 

Let’s see how to blink an LED to learn about controlling GPIO pins and get started on Pico.

Blinking external LED using GPIO pins of Pi Pico

 

Installation of MicroPython for Raspberry Pi Pico

First, we need to set up our computer/laptop to upload codes to Pico. This can be done in 3 simple steps:

  • Install Thonny IDE
  • Add MicroPython to Pico
  • Upload codes

 To install Thonny, go to “thonny.org”

Thonny IDE

And click on the link to download for your system specification.

Thonny IDE Installation

The installation process is simple and will only take a few seconds.

 

Thonny IDE Window

Now, connect the Pico to the COM port and open Thonny, go to “tools” à “options” à “interpreter” à select “MicroPython (Raspberry Pi Pico)” as the interpreter and select the COM port being used.

 

Installing MicroPython on Raspberry Pi Pico

(NOTE: There’ll be a prompt asking to install MicroPython, click yes (as shown in the figure) and then you can check in shell that Pico is connected.)

Blink LED Circuit using Raspberry Pi Pico

 

Circuit connections for Pico is very simple. Connect the LED in series with 220 ohm or 100 ohm Resistor. Connect the other pin of Resistor to the Ground pin of the Pico. Connect the GPIO 2 pin of Pico to the LED positive terminal. Now the circuit connection is complete.

Blink LED using Pico

 

Code for Blinking LED using Raspberry Pi Pico

The code written is simple. GPIO pins are imported from Machine and a Timer is used to create delay of 1 second.

from machine import Pin, Timer
led = Pin(2, Pin.OUT)
LED_state = True
tim = Timer()
def tick(timer):
global led, LED_state
LED_state = not LED_state
led.value(LED_state)
tim.init(freq=1, mode=Timer.PERIODIC, callback=tick) 
 

It’s a dream come true for many hobbyists to have low power consumption and high-performance applications by RP2040 and Pico. With release of Pico, Raspberry Pi has indeed set new precedence by building their board and silicon! With that they have certainly shaken the microcontroller market. With the power of MicroPython, this little microcontroller is going to cause wonders!

0 comments

Leave a comment

All blog comments are checked prior to publishing