element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Ralph Yamamoto's Blog QT Py RP2040
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ralphjy
  • Date Created: 15 May 2021 4:41 AM Date Created
  • Views 1814 views
  • Likes 6 likes
  • Comments 1 comment
  • seeeduino xiao expansion board
  • oled
  • adafruit_ssd1306
  • adafruit qt py rp2040
  • circuitpython
Related
Recommended

QT Py RP2040

ralphjy
ralphjy
15 May 2021

Adafruit now has an RP2040 version of their QT Py:  Adafruit QT Py RP2040 .

 

Another nice compact design with USB-C, a Stemma QT connector plus 8MB of SPI Flash and a NeoPixel LED.  It is interesting that they kept the castellated pads, but because the RP2040 and Flash memory are on the underside of the board - you would need to put a cutout in the host PCB to attach it.

 

imageimage

 

I have a couple of Xiao accessory boards from Seeed that I want to use with with this board - the Grove shield Grove-Shield-for-Seeeduino-XIAO and the Xpansion board Seeeduino-XIAO-Expansion-board .  The QT Py is pin compatible with the Xiao.

imageimage

I'll need to remove the SWD spring pins from the Xpansion board as they will hit the Flash memory chip.

 

I decided to try the QT Py RP2040 on the Xpansion board first since it will be nice to be able to use the OLED display and the SD card.  I'm programming the RP2040 with CircuitPython since I've been using it with the Adafruit FunHouse .

 

I've found that the one of the tricky parts of using CircuitPython (or MicroPython) is that you need to have the required libraries loaded on the target device (usually compiled libraries - *.mpy - to save space).  I noticed in the Adafruit CircuitPython libraries bundle that each library has a requirements.txt file that lists other libraries that it might be dependent upon.  If you forget a dependent library, you'll get a message like: ImportError: no module named 'adafruit_framebuf'.

 

 

For a quick test of the QT Py RP2040 and the OLED, I used the ssd1306_framebuftest.py example with only a few minor tweaks.  The program is renamed code.py so that it will automatically execute when it is uploaded.

 

code.py  (ssd1306_framebuftest.py)

# SPDX-FileCopyrightText: Tony DiCola
# SPDX-License-Identifier: CC0-1.0


# Basic example of using framebuf capabilities on a SSD1306 OLED display.
# This example and library is meant to work with Adafruit CircuitPython API.


# Import all board pins.
import time
import board
import busio
from digitalio import DigitalInOut


# Import the SSD1306 module.
import adafruit_ssd1306


# Create the I2C interface.
i2c = busio.I2C(board.SCL, board.SDA)
# A reset line may be required if there is no auto-reset circuitry
#reset_pin = DigitalInOut(board.D5)


# Create the SSD1306 OLED class.
# The first two parameters are the pixel width and pixel height.  Change these
# to the right size for your display!
# The I2C address for these displays is 0x3d or 0x3c, change to match
# A reset line may be required if there is no auto-reset circuitry
display = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)


print(
    "Framebuf capability test - these are slow and minimal but don't require"
    "a special graphics management library, only `adafruit_framebuf`"
)


print("Pixel test")
# Clear the display.  Always call show after changing pixels to make the display
# update visible!
display.fill(0)
display.show()


# Set a pixel in the origin 0,0 position.
display.pixel(0, 0, 1)
# Set a pixel in the middle position.
display.pixel(display.width // 2, display.height // 2, 1)
# Set a pixel in the opposite corner position.
display.pixel(display.width - 1, display.height - 1, 1)
display.show()
time.sleep(1.0)


print("Lines test")
# we'll draw from corner to corner, lets define all the pair coordinates here
corners = (
    (0, 0),
    (0, display.height - 1),
    (display.width - 1, 0),
    (display.width - 1, display.height - 1),
)


display.fill(0)
for corner_from in corners:
    for corner_to in corners:
        display.line(corner_from[0], corner_from[1], corner_to[0], corner_to[1], 1)
display.show()
time.sleep(1.0)


print("Rectangle test")
display.fill(0)
w_delta = display.width / 10
h_delta = display.height / 10
for i in range(11):
    display.rect(0, 0, int(w_delta * i), int(h_delta * i), 1)
display.show()
time.sleep(1.0)


print("Text test")
display.fill(0)
try:
    display.text("hello world", 0, 0, 1)
    display.show()
    time.sleep(1.0)
    display.fill(0)
    char_width = 6
    char_height = 8
    chars_per_line = display.width // 6
    for i in range(255):
        x = char_width * (i % chars_per_line)
        y = char_height * (i // chars_per_line)
        display.text(chr(i), x, y, 1)
    display.show()
except OSError:
    print(
        "To test the framebuf font setup, you'll need the font5x8.bin file from "
        + "https://github.com/adafruit/Adafruit_CircuitPython_framebuf/tree/master/examples"
        + " in the same directory as this script"
    )

 

Here is the output on the Mu Editor Serial Console:

image

 

And a short video of the display test:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

This will be a very useful tool and it also has an RTC and battery support using a PMIC, so it is ideal for remote logging.  The 4 Grove ports on the Xpansion board and the Stemma QT port on the QT Py make it easy to add sensors via I2C or UART.  Unfortunately, the Stemma QT connection will obscure the OLED - although I could route the cable under the QT Py.

 

In the future I'll switch to programming the QT Py RP2040 using Mbed with the Arduino IDE.

  • Sign in to reply

Top Comments

  • DAB
    DAB over 4 years ago +1
    Nice update. DAB
  • DAB
    DAB over 4 years ago

    Nice update.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube