Posts

Showing posts with the label Raspberry Pi Pico W

micropython_ssd1306  on the Raspberry Pi Pico 2 to control SSD1306 OLED

Image
Installing  micropython_ssd1306  on the Raspberry Pi Pico 2 with Thonny This video explains how to install the  micropython_ssd1306  library (the SSD1306 OLED driver for MicroPython) on the Raspberry Pi Pico 2 using the Thonny Package Manager. Connect your Raspberry Pi Pico 2 (with MicroPython firmware) to your computer. Open Thonny and configure the interpreter for the Raspberry Pi Pico 2 (MicroPython). In the top menu, go to Tools > Manage packages... Search for  micropython-ssd1306  and click Install. Connection: Exercise code: # mpy_pico2_ssd1306.py # MicroPython exercise running on Raspberry Pi Pico 2 with RP2350 # to control 128x64 SSD1306 OLED. # # https://coxxect.blogspot.com/2026/10/installing-micropythonssd1306-on.html # import time from machine import Pin, I2C from ssd1306 import SSD1306_I2C from framebuf import FrameBuffer i2c = I2C(0) print(i2c) print(i2c.scan()) oled = SSD1306_I2C(128, 64, i2c) prin...

MicroPython _thread exercise

Image
The purpose of this exercise is to test the behavior of MicroPython _thread, specifically for Raspberry Pi Pico series, whether _thread.start_new_thread() can provide real multi-core parallel speedup for pure Python CPU-bound work.  Connection: mpy_thread_smp_bench.py # mpy_thread_smp_bench.py # # Purpose: # Simple MicroPython benchmark to test whether _thread.start_new_thread() # can provide real multi-core parallel speedup for pure Python CPU-bound work. # # Method: # 1. Run a CPU-bound loop in the main thread and measure the duration. # This is the single-thread baseline. # # 2. Run the same CPU-bound loop in two threads: # - one in the main thread # - one in a newly created _thread # # 3. Measure: # - duration of thread 0 # - duration of thread 1 # - total wall-clock time from starting both threads until both finish # # Interpretation: # Let single-thread duration be T. # # If the two CPU jobs run fully in...

Raspberry Pi Pico 2 W/CircuitPython 10.0.3: Load animated GIFs from MicroSD, display them on a 240*240 GC9A01 LCD using gifio.OnDiskGif.

Image
Previous posts show Basic setup of 1.28 inch 240x240 Round Display with GC9A01 SPI on Raspberry Pi Pico 2 W/CircuitPython 10.0.3  and display bmp images from SD using displayio.OnDiskBitmap()/adafruit_imageload.load()  This post shows how to display animated GIFs from MicroSD. The connection between Raspberry Pi Pico 2 W, GC9A01 LCD and the MicroSD Module refers to the last post, display bmp images from SD using displayio.OnDiskBitmap()/adafruit_imageload.load()   Ref: https://docs.circuitpython.org/en/latest/shared-bindings/gifio/index.html#gifio.OnDiskGif Exercise Code: cpy_rpPicoW_gc9a01_sd_OnDiskGif.py. Cooperate with displayio, this mode is relatively slow. """ Raspberry Pi Pico 2 W/CircuitPython 10.0.3 with 1.28" 240x240 Round GC9A01 SPI IPS LCD Display animated GIF in SD, using gifio.OnDiskGif. Cooperate with displayio, this mode is relatively slow. https://coxxect.blogspot.com/2026/02/raspberry-pi-pico-2-wcircuitpython-1003.html ref: https:...

Pico 2 W/CircuitPython 10.0.3 Display bmp images in SD, using displayio.OnDiskBitmap()/adafruit_imageload.load().

Image
Raspberry Pi Pico 2 W with CircuitPython 10.0.3, to display BMP images from an MicroSD card on a 240*240 GC9A01 Round LCD , using displayio.OnDiskBitmap() and adafruit_imageload.load(). Reference: -  displayio.OnDiskBitmap() -  adafruit_imageload.load() All bmp were resized and converted from jpg to 240*240 RGB888 bmp using FFmpeg . Connection: Raspberry Pi Pico 2 W ===================== GP28| GND | GP27| GP26| Run | GP22| ------- LCD_BLK ------------+ GND | | GP21| ------- LCD_DC ---------+ | GP20| ------- LCD_RES-------+ | | +------- SD_MISO|GP12 GP19| MOSI - SPI_SDA ----+ | | | | +----- SD_CS |GP13 GP18| SCK - SPI_SCL --+ | | | | | | |GND GND | | | | |...

Downloading Bitmap via WiFi with CircuitPython, Saving to Local File System, and Displaying on LCD using OnDiskBitmap.

Image
In my previous post , I demonstrated basic exercises running on the Raspberry Pi Pico 2 W with CircuitPython 10.0.3, displaying graphics on a 1.28‑inch IPS module (GC9A01 + CST816S, 240×240 round, 4‑wire SPI) . In this post, I present exercises using CircuitPython 10.0.3 on the Raspberry Pi Pico 2 W to download a bitmap via WiFi, save it to the local file system, and display it on the GC9A01 LCD using OnDiskBitmap. The BMP in my test was resized and converted from JPG to BMP(240*240 RGB888) using FFmpeg . cpy_rpPicoW_gc9a01_OnDiskBitmap_wifi.py """ Raspberry Pi Pico 2 W/CircuitPython 10.0.3 with 1.28" 240x240 Round GC9A01 SPI IPS LCD Download bmp to local file system and display it using OnDiskBitmap ~ Single bmp. In this exercise, Pico 2 W download image from web server, save it on CircuitPython local filesystem, named "image.bmp, then display it on 1.28" 240x240 Round GC9A01 SPI IPS LCD using OnDiskBitmap. https://coxxect.blogspot.com/2026/01/...

Control onboard LED of Raspberry Pi Pico 2/2W using MicroPython/CircuitPython

Image
The onboard LED on Raspberry Pi Pico and Pico 2 is connected to GPIO25. On Pico W and Pico 2 W, it's connected to the wireless chip. Following are exercise to control the onboard LED using MicroPython/CircuitPython, tested on Pico 2 and Pico 2 W. mpy_rp2_led.py """ MicroPython on Raspberry Pi Pico 2/2W to control onboard LED """ import os, sys import time #import board #from digitalio import DigitalInOut, Direction sys_info_text = sys.implementation[0] + " " + os.uname()[3] +\ "\nrun on " + os.uname()[4] print("=======================================") print(sys_info_text) print("=======================================") led = machine.Pin("LED", machine.Pin.OUT) print("led:", led) # Control onboard led using led.on() and led.off() while True: led.on() time.sleep(0.5) led.off() time.sleep(0.5) """ # Toggle onboard led using led.togg...

Solve FutureWarning: I2CDisplay moved from displayio to i2cdisplaybus and I2CDisplay renamed I2CDisplayBus

Image
In CircuitPython 8 and before, I2CDisplay is in displayio . In CircuitPython 9+, it's moved to i2cdisplaybus.I2CDisplayBus . This exercise define display_bus in try:...except ImportError:...block, using displayio.I2CDisplay on CircuitPython 8, and i2cdisplaybus.I2CDisplayBus on CircuitPython 9. rp2040_ssd1306_displayio_circuitpython89.py """ Solve: FutureWarning: I2CDisplay moved from displayio to i2cdisplaybus FutureWarning: I2CDisplay renamed I2CDisplayBus In CircuitPython 8 and before, I2CDisplay is in displayio (https://docs.circuitpython.org/en/8.2.x/shared-bindings/displayio/index.html#displayio.I2CDisplay). In CircuitPython 9+, it's moved to i2cdisplaybus.I2CDisplayBus (https://docs.circuitpython.org/en/latest/shared-bindings/i2cdisplaybus/index.html#i2cdisplaybus.I2CDisplayBus). This exercise define display_bus in try:...except ImportError:...block, using displayio.I2CDisplay on CircuitPython 8, and i2cdisplaybus.I2CDisplayBus on Ci...

SSD1306 I2C OLED + 4X4 Matrix Keypad Module on RP2040/CircuiyPython 9

Image
Exercises run on WeAct Studio Pico (rp2040) running CircuitPython 9.0.0-beta.0 with 0.96 inch 128x64 SSD1306 I2C OLED with 4X4 Matrix Keypad Module , to display on OLED using using adafruit_displayio_ssd1306, and detect 4X4 key-matrix using Keypad Module. Libraries need: - adafruit_displayio_ssd1306.mpy - adafruit_display_text folder (If you don't know how to download CircuitPython library bundle and upload to CircuitPython device, read related post RP2040/CircuitPython display on SH1107 SPI OLED ) For SSD1306 I2C OLED: displayio.I2CDisplay  moved from displayio to i2cdisplaybus and renamed I2CDisplayBus. You will not find I2CDisplay in current latest CircuitPython 9 displayio . In CircuitPython 9, it is moved to i2cdisplaybus.I2CDisplayBus . Currently, if you use displayio.I2CDisplay in CircuitPython 9 (actually it will be switched to I2CDisplayBus), it will not raise error, but raise warning: FutureWarning: I2CDisplay moved from ...