Skip to main content

RP2350

This chapter includes the following sections. Please read as needed:

MicroPython Getting Started Tutorial​

New to ESP32 MicroPython development and looking for a quick start? We have prepared a comprehensive ESP32 MicroPython Getting Started Tutorial for you.

Note: This tutorial uses the ESP32-S3-Zero as a teaching example, and all hardware code is based on its pinout. Before proceeding, we recommend checking the pinout diagram of your specific development board to ensure the pin configuration is correct.

Pico Quick Start​

Get MicroPython Firmware​

Get the onboard MicroPython firmware for the RP2350 PLUS.

Installing MicroPython Firmware in Thonny

Install Thonny IDE​

After installation, you need to configure the language and board environment for the first time. Since we are using Pico/Pico2, make sure to select the Raspberry Pi option for the board environment.

Selecting the MicroPython Interpreter in Thonny

Selecting the RP2350 PLUS Serial Port in Thonny

Example​

Transparent_Test​

Example Description​

  • This example uses the RP2350 PLUS and MicroPython to drive a 128 × 64 SSD1312 OLED. The project uses 4-wire SPI by default, and also supports switching the OLED module to an I2C interface.
  • SPI uses SPI1 by default, operating in SPI mode 0 with a clock frequency of 4 MHz. The OLED only receives data, so MISO does not need to be connected.
  • I2C uses I2C0 by default, with a clock frequency of 400 kHz and a 7-bit address of 0x3C. The hardware interface selection of the module must match the BUS configuration in config.py.
  • The driver class inherits MicroPython's framebuf.FrameBuffer, uses a 1024-byte framebuffer to store a 128 × 64 monochrome image, and provides interfaces for clearing the screen, refreshing, drawing points, lines, rectangles, text, contrast, color inversion, and display on/off control.
  • By default, it runs the OLED comprehensive example, displaying in sequence a title page, Chinese "微雪", a product info image, a night scene line art, and a dashboard. The project also provides a continuously rotating wireframe cube example, which can be switched in config.py.

Project File Description:

FileDescription
main.pyProgram entry; creates an SPI or I2C display object based on the configuration, and starts the selected example
config.pyCommunication interface, pins, speed, I2C address, and example program configuration
ssd1312.pySSD1312 initialization, SPI/I2C communication, framebuffer refresh, and display control
demo.pyOLED comprehensive example, including text, graphics, and dot-matrix content
cube.pyRotating wireframe cube example
glyphs.py32 × 41 monochrome dot-matrix data and drawing functions for Chinese "微雪"

Hardware Connection​

Disconnect power before wiring

The OLED operating voltage is 3.3 V. Do not connect VCC to a 5 V power supply.

The project is configured for 4-wire SPI by default. Wire according to the table below:

0.96inch Transparent OLEDRP2350 PLUS
VCC3.3 V
GNDGND
DINGP11 / SPI1 TX
CLKGP10 / SPI1 SCK
CSGP9
DCGP8
RSTGP12
ENNot connected

The module's EN pin is enabled by default, and this example does not use it. After wiring, connect the RP2350 PLUS to the computer using a USB cable that supports data transfer.

To use I2C, first switch the interface selection solder pad on the back of the OLED module to I2C, then wire according to the table below:

0.96inch Transparent OLEDRP2350 PLUS
VCC3.3 V
GNDGND
DIN / SDAGP4 / I2C0 SDA
CLK / SCLGP5 / I2C0 SCL
RSTGP12
CSNot connected
DCNot connected
ENNot connected

Also change the communication interface in config.py to:

BUS = "I2C"

The I2C SDA and SCL require pull-up resistors; if the module does not have integrated pull-up resistors, external appropriate pull-up resistors are needed.

Code Analysis​

  • create_display(): Reads BUS from config.py, and creates an SSD1312_SPI or SSD1312_I2C object based on the configuration; throws an exception if the configuration value is not SPI or I2C.
  • SSD1312._initialize(): First performs a hardware reset of the OLED via GP12, then sends SSD1312 initialization commands, clears the framebuffer, and turns on the display.
  • SSD1312.show(): Writes the 128 × 64 framebuffer to the OLED in 8 pages, transmitting 128 bytes of display data per page.
  • demo.run(): Cycles through drawing a title page, Chinese dot-matrix, product info image, night scene line art, and dashboard, and calls show() to refresh the screen after each drawing.
  • glyphs.draw_text(): Parses 32 × 41 monochrome dot-matrix data bit by bit, used to display Chinese "微雪".
  • cube.run(): Rotates and perspective-projects the cube's 8 vertices, then connects 12 edges, drawing and refreshing a frame approximately every 20 ms.

In config.py, select the example program via DEMO:

# OLED comprehensive example
DEMO = "oled"

# Rotating wireframe cube example
# DEMO = "cube"

Both demo.run() and cube.run() are continuously running loops, so only one example can be run at a time.

Run the Example​

  1. Install the applicable MicroPython firmware for the RP2350 PLUS, then open Thonny.
  2. In Thonny, select the MicroPython (Raspberry Pi Pico) interpreter, and select the serial port corresponding to the board.
  3. Upload main.py, config.py, ssd1312.py, demo.py, cube.py and glyphs.py all to the root directory of the board's file system.
  4. Reset the board or run main.py in Thonny. After successful initialization, the Shell outputs:
SSD1312 initialized using SPI

When using I2C, SPI in the output will change to I2C. When uploading files, keep the original file names. main.py will execute automatically after the board boots.

Expected Behavior​

After setting DEMO to "oled" by default, the OLED cycles through the following displays in order:

OrderDisplay ContentDuration
1WAVESHARE, RP2350 and SSD1312 OLED title page2 sec
2Chinese "微雪" dot-matrix2 sec
30.96 OLED 128x64 product info image2 sec
4Stars, crescent moon, mountain peaks, and pine tree line art3 sec
5Dashboard composed of RP2350, interface status, battery icon, and line chart5 sec

0.96inch Transparent OLED Demo

After setting DEMO to "cube", the OLED continuously displays a wireframe cube rotating around the vertical axis, with the program refreshing a frame approximately every 20 ms.