Raspberry Pi Pico Getting Started Tutorial with MicroPython
Raspberry Pi Pico Getting Started Tutorial with MicroPython based on ARM RP2040 Microcontroller. Raspberry Pi Pico LED blink Code Thonny IDE
- Suitable forB.Tech/Diploma RPi Pico students
- Build time1-2 weeks
- LevelBeginner
- Available atAjvika Labs, Kakinada
About this project
Overview
In this Getting Started tutorial, we will learn about the
Raspberry Pi Pico
, a brand new exciting Microcontroller board based on
RP2040 Microcontroller
from the
Raspberry Pi Foundation
. The Raspberry Pi Pico is a low-cost Arm-based microcontroller that we can program using
C/C++
and
MicroPython
Over the years Raspberry Pi boards have become a must tool for students, hobbyists,s or Industrialists. But when it comes to cost, the Raspberry Pi Board is overtaken by
Arduino, ESP32, STM32
, or other
AVR, ARM, PIC
Microcontrollers. The Raspberry Pi computer costs around
35-40$
whereas the other microcontrollers barely cost
2-5$
only. This is the reason why
Raspberry Pi Foundation
released their low-cost powerful competitive Raspberry Pi Pico Board with RP2040, a
Dual Core ARM Cortex-M0+ Microcontroller
The tutorial covers the RP2040 Microcontroller, its
features
&
specifications
. We will also learn about the Raspberry Pi Pico Board, its layout, and specifications. The detailed guide of Raspberry Pi Pico Pins like
ADC pins, I2C Pins, SPI Pins, UART
, etc can help you to interface any
sensors
or
module
with this powerful board.
Since it’s a
Raspberry Pi Pico getting started tutorial
, so we will only program the device using Micropython. For that, you can either use
Thonny IDE
or you can also go with
uPyCraft IDE
. In some other tutorials, we will learn how to program Raspberry Pi Pico with C/C++. Even the
Arduino IDE
will support Raspberry Pie Pico in the future as it is in the development phase now. We will go through the basic
Raspberry Pi Pico LED Blink Code
& check the board functionality.
What is RP2040 Microcontroller?
Earlier all the Raspberry Pi boards like
Raspberry Pi 3
or
or
Raspberry Pi Zero
featured Broadcom Processors like
BCM2835, BCM2836, BCM2711
etc. The RP2040 chip was announced on 21st January 2021 and is the first processor designed by the Raspberry Pi Foundation.
The RP2040 is a
32-bit
dual
ARM Cortex-M0+ microcontroller
integrated circuit released at the same time as part of the Raspberry Pi Pico board. The processor is a low-cost microcontroller and costs around
US$4
. The chip is
40nm
silicon in a
7×7 mm QFN-56
package.
The RP2040 contains two
ARM Cortex-M0+
cores clocked at
133 MHz
together with
264 KB
of RAM. The Program memory is external and supports up to
16 MB
. The device has everything you expect from a modern microcontroller like
UARTS, SPI,
and
I2C
ports, and there are timers, PWM, DMA, and a 12-bit analog-to-digital converter
(ADC)
Meaning of RP2040
The name RP2040 has a very interesting meaning explained below.
1. RP means
: Raspberry Pi
2. Number 2 means
: Processor Cores as it is a dual-core microcontroller. So, the value is 2.
3. Number 0 means
: Type of Processor Core as it is ARM Cortex-M0+. So, the value is 0.
4. Number 4 means
: Represents On-chip RAM. RP2040 has 264 KB of RAM. The formula to get 4 value is: floor (log2 (ram / 16k)). So, the value is 4.
5. Number 0 means
: Represents On-chip Flash. As there is no on-chip flash, the value is 0.
RP2040 Key features:
133MHz
dual ARM Cortex-M0+ cores
264kB SRAM in six independent banks
Support for up to
16MB
of off-chip Flash memory via dedicated QSPI bus
DMA
controller
Fully-connected AHB crossbar
Interpolator and integer divider peripherals
On-chip programmable
LDO(Low-dropout_regulator)
to generate core voltage
2 on-chip
PLLs
to generate USB and core clocks
30 GPIO
pins, 4 of which can be used as
analog inputs
Introduction to Raspberry Pi Pico
The Raspberry Pi Pico is the first microcontroller board based on the RP2040. It looks a lot like other
microcontroller boards
with the MCU in the center, a micro-USB connector on one end, and a row of contacts along each side. A 3-pin
debug connector
is available at the other end of the board.
The Raspberry Pi Pico measures
51 by 21 mm
, which is the exact same size as an ESP32 Pico Kit & slightly larger than an Arduino Nano or Micro. The Pico comes with
2 MB of QSPI Flash memory
and 25 of the 30 GPIO pins of the RP2040 have been brought out on the extension connectors. The board is
breadboard friendly
and fits perfectly on breadboard.
Features of Raspberry Pi Pico
Following are the features of Raspberry Pi Pico Board.
1. Based on
RP2040
Microcontroller
2 MB
of SPI Flash Memory
Type B Micro-USB
port for power & programming
40 DIP
style IO Pins
5. 3-pin ARM Serial Wire Debug (SWD) interface
12 MHz Crystal
oscillator
7. Boot Selection Button
8. Programmable LED connected to GPIO 25
3.3V
Fixed Output
Buck-Boost SMPS Converter
Raspberry Pi Pico Pinout
This is a top view of the pinouts on the Raspberry Pi Pico. The pin labels are on the bottom of the board.
There are
40-pin
on the Raspberry Pi Pico. Out of those
40 pins
, 26 pins are Input-Output (IO Pins). All those 14 pins are analog, digital, and other Serial Pins. There are
14 power
and system-related pins. The remaining 3 more pins are used for
SWD Debugging
There are two I2C peripherals available, I2C0 and I2C1. Similarly, there are two SPI peripherals, SPI0 and SPI1The number of UART Pins are also two, UART0 and UART1. You can assign any of these to the pins on which they are available.
Before you start using Raspberry Pi Pico, you have to
solder 40 pin male headers
, 20 on each side of the board.
Programming Raspberry Pi Pico
The Pi Pico can be programmed using
C/C++
or
Python
, among other languages. Pico is adaptable to a vast range of applications and skill levels, and getting started is as easy as dragging and dropping a file. If you are working with C, then it is recommended to use a
Linux based system
like a Raspberry Pi Computer as it is easy to download the SDK and write C Programs in Linux.
But I will recommend using
MicroPython
to program the Raspberry Pi Pico Board. MicroPython is a Python Language Interpreter that is developed for Microcontrollers and
embedded systems
. The
Syntax for MicroPython
is very similar to Python. So, if you worked with Python, then working with MicroPython will be very easy.
To program the Raspberry Pi Pico using Micropython, you can either use:
1. Thonny IDE
2. uPyCraft IDE
But before getting started with Raspberry Pi Pico, you have to install MicroPython on Raspberry Pi Pico Board.
Installing MicroPython on Raspberry Pi Pico
Push and hold the BOOTSEL button on the Pico, & then immediately connect the Pico Board to your computer using a micro USB cable. Release BOOTSEL once the drive RPI-RP2 appears on your computer.
Open the
RPI-RP2 drive
that appears in the Drives tab.
Visit the Raspberry Pi Pico Official Documentation page from here:
Raspberry Pi Documentation
Download the MicroPython UF2 file from the MicroPython tab.
Drag and drop the UF2 file onto the RPI-RP2 drive. The Raspberry Pi Pico will reboot and will now run MicroPython.
Getting Started with Raspberry Pi Pico using MicroPython on Thonny IDE
Now let us get started with Raspberry Pi Pico using
MicroPython on Thonny IDE
. First you have to download Thonny from the
https://thonny.org/
Connect the Raspberry Pi Pico to your computer. Then from Thonny go to
Tools
> Options and click on the
Interpreter
tab. From the interpreter dropdown list, select
MicroPython (Raspberry Pi Pico)
. The port dropdown menu can be left to automatically detect the Pico. Click
Ok
to close.
When you plugin the pico Board, a firmware installation tab will appear for raspberry pi pico. Click on
Install
& some files will be downloaded.
After successful installation, the MicroPython version and Raspberry board will appear in the
Python Shell
. To test we can write a quick
print function
to say
“Hello World”
. Press Enter to run the code. You will get Hello World as a response.
Writing a blink program for the onboard LED of pico
The on-board LED on the Raspberry Pi Pico is connected to
GPIO25
. Copy the following code and paste it on the editor window.
from
machine
import
Pin
i
In this Getting Started tutorial, we will learn about the
Raspberry Pi Pico
, a brand new exciting Microcontroller board based on
RP2040 Microcontroller
from the
Raspberry Pi Foundation
. The Raspberry Pi Pico is a low-cost Arm-based microcontroller that we can program using
C/C++
and
MicroPython
Over the years Raspberry Pi boards have become a must tool for students, hobbyists,s or Industrialists. But when it comes to cost, the Raspberry Pi Board is overtaken by
Arduino, ESP32, STM32
, or other
AVR, ARM, PIC
Microcontrollers. The Raspberry Pi computer costs around
35-40$
whereas the other microcontrollers barely cost
2-5$
only. This is the reason why
Raspberry Pi Foundation
released their low-cost powerful competitive Raspberry Pi Pico Board with RP2040, a
Dual Core ARM Cortex-M0+ Microcontroller
The tutorial covers the RP2040 Microcontroller, its
features
&
specifications
. We will also learn about the Raspberry Pi Pico Board, its layout, and specifications. The detailed guide of Raspberry Pi Pico Pins like
ADC pins, I2C Pins, SPI Pins, UART
, etc can help you to interface any
sensors
or
module
with this powerful board.
Since it’s a
Raspberry Pi Pico getting started tutorial
, so we will only program the device using Micropython. For that, you can either use
Thonny IDE
or you can also go with
uPyCraft IDE
. In some other tutorials, we will learn how to program Raspberry Pi Pico with C/C++. Even the
Arduino IDE
will support Raspberry Pie Pico in the future as it is in the development phase now. We will go through the basic
Raspberry Pi Pico LED Blink Code
& check the board functionality.
What is RP2040 Microcontroller?
Earlier all the Raspberry Pi boards like
Raspberry Pi 3
or
or
Raspberry Pi Zero
featured Broadcom Processors like
BCM2835, BCM2836, BCM2711
etc. The RP2040 chip was announced on 21st January 2021 and is the first processor designed by the Raspberry Pi Foundation.
The RP2040 is a
32-bit
dual
ARM Cortex-M0+ microcontroller
integrated circuit released at the same time as part of the Raspberry Pi Pico board. The processor is a low-cost microcontroller and costs around
US$4
. The chip is
40nm
silicon in a
7×7 mm QFN-56
package.
The RP2040 contains two
ARM Cortex-M0+
cores clocked at
133 MHz
together with
264 KB
of RAM. The Program memory is external and supports up to
16 MB
. The device has everything you expect from a modern microcontroller like
UARTS, SPI,
and
I2C
ports, and there are timers, PWM, DMA, and a 12-bit analog-to-digital converter
(ADC)
Meaning of RP2040
The name RP2040 has a very interesting meaning explained below.
1. RP means
: Raspberry Pi
2. Number 2 means
: Processor Cores as it is a dual-core microcontroller. So, the value is 2.
3. Number 0 means
: Type of Processor Core as it is ARM Cortex-M0+. So, the value is 0.
4. Number 4 means
: Represents On-chip RAM. RP2040 has 264 KB of RAM. The formula to get 4 value is: floor (log2 (ram / 16k)). So, the value is 4.
5. Number 0 means
: Represents On-chip Flash. As there is no on-chip flash, the value is 0.
RP2040 Key features:
133MHz
dual ARM Cortex-M0+ cores
264kB SRAM in six independent banks
Support for up to
16MB
of off-chip Flash memory via dedicated QSPI bus
DMA
controller
Fully-connected AHB crossbar
Interpolator and integer divider peripherals
On-chip programmable
LDO(Low-dropout_regulator)
to generate core voltage
2 on-chip
PLLs
to generate USB and core clocks
30 GPIO
pins, 4 of which can be used as
analog inputs
Introduction to Raspberry Pi Pico
The Raspberry Pi Pico is the first microcontroller board based on the RP2040. It looks a lot like other
microcontroller boards
with the MCU in the center, a micro-USB connector on one end, and a row of contacts along each side. A 3-pin
debug connector
is available at the other end of the board.
The Raspberry Pi Pico measures
51 by 21 mm
, which is the exact same size as an ESP32 Pico Kit & slightly larger than an Arduino Nano or Micro. The Pico comes with
2 MB of QSPI Flash memory
and 25 of the 30 GPIO pins of the RP2040 have been brought out on the extension connectors. The board is
breadboard friendly
and fits perfectly on breadboard.
Features of Raspberry Pi Pico
Following are the features of Raspberry Pi Pico Board.
1. Based on
RP2040
Microcontroller
2 MB
of SPI Flash Memory
Type B Micro-USB
port for power & programming
40 DIP
style IO Pins
5. 3-pin ARM Serial Wire Debug (SWD) interface
12 MHz Crystal
oscillator
7. Boot Selection Button
8. Programmable LED connected to GPIO 25
3.3V
Fixed Output
Buck-Boost SMPS Converter
Raspberry Pi Pico Pinout
This is a top view of the pinouts on the Raspberry Pi Pico. The pin labels are on the bottom of the board.
There are
40-pin
on the Raspberry Pi Pico. Out of those
40 pins
, 26 pins are Input-Output (IO Pins). All those 14 pins are analog, digital, and other Serial Pins. There are
14 power
and system-related pins. The remaining 3 more pins are used for
SWD Debugging
There are two I2C peripherals available, I2C0 and I2C1. Similarly, there are two SPI peripherals, SPI0 and SPI1The number of UART Pins are also two, UART0 and UART1. You can assign any of these to the pins on which they are available.
Before you start using Raspberry Pi Pico, you have to
solder 40 pin male headers
, 20 on each side of the board.
Programming Raspberry Pi Pico
The Pi Pico can be programmed using
C/C++
or
Python
, among other languages. Pico is adaptable to a vast range of applications and skill levels, and getting started is as easy as dragging and dropping a file. If you are working with C, then it is recommended to use a
Linux based system
like a Raspberry Pi Computer as it is easy to download the SDK and write C Programs in Linux.
But I will recommend using
MicroPython
to program the Raspberry Pi Pico Board. MicroPython is a Python Language Interpreter that is developed for Microcontrollers and
embedded systems
. The
Syntax for MicroPython
is very similar to Python. So, if you worked with Python, then working with MicroPython will be very easy.
To program the Raspberry Pi Pico using Micropython, you can either use:
1. Thonny IDE
2. uPyCraft IDE
But before getting started with Raspberry Pi Pico, you have to install MicroPython on Raspberry Pi Pico Board.
Installing MicroPython on Raspberry Pi Pico
Push and hold the BOOTSEL button on the Pico, & then immediately connect the Pico Board to your computer using a micro USB cable. Release BOOTSEL once the drive RPI-RP2 appears on your computer.
Open the
RPI-RP2 drive
that appears in the Drives tab.
Visit the Raspberry Pi Pico Official Documentation page from here:
Raspberry Pi Documentation
Download the MicroPython UF2 file from the MicroPython tab.
Drag and drop the UF2 file onto the RPI-RP2 drive. The Raspberry Pi Pico will reboot and will now run MicroPython.
Getting Started with Raspberry Pi Pico using MicroPython on Thonny IDE
Now let us get started with Raspberry Pi Pico using
MicroPython on Thonny IDE
. First you have to download Thonny from the
https://thonny.org/
Connect the Raspberry Pi Pico to your computer. Then from Thonny go to
Tools
> Options and click on the
Interpreter
tab. From the interpreter dropdown list, select
MicroPython (Raspberry Pi Pico)
. The port dropdown menu can be left to automatically detect the Pico. Click
Ok
to close.
When you plugin the pico Board, a firmware installation tab will appear for raspberry pi pico. Click on
Install
& some files will be downloaded.
After successful installation, the MicroPython version and Raspberry board will appear in the
Python Shell
. To test we can write a quick
print function
to say
“Hello World”
. Press Enter to run the code. You will get Hello World as a response.
Writing a blink program for the onboard LED of pico
The on-board LED on the Raspberry Pi Pico is connected to
GPIO25
. Copy the following code and paste it on the editor window.
from
machine
import
Pin
i
Technologies used
Hardware components
- ESP32
- Arduino
- Raspberry Pi
- STM32
Software & tools
- Arduino IDE
- Thonny
- MicroPython
What you get
- Working project / hardware kit, tested before delivery
- Complete source code with explanation
- Project demo and guidance for your viva
- Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed.
Payment is in two parts:
• 50% advance to start the project
• Remaining 50% before delivery
Note:
• Documentation and PPT are not included by default
• If you need documentation/PPT, it can be arranged for extra time and cost
We'll confirm the exact timeline and cost with you after reviewing your requirements.