Skip to content

A small Raspberry project

Adafruit QtPy RP2040

I’ve been working on getting a small bus converted to a camper for over a year now (see here for details) and in between working in it, I work on the tech I’m going to put in it.
One of those things is a temperature and humidity monitor which I wanted to have on display 24/7.

For that to work I had to look into tech that draws next to nothing in power and was programmable. Thankfully the lovely Lada Ada over at Adafruit Industries had made the Raspberry Pi Pico with the very useful RP2040 chip into a even smaller form factor with the QtPy RP2040. And with it you could daisy chain other sensors, monitors and more via the STEMMA QT connection onboard.

So, for this project I chose the QtPy RP2040, the SHT40 temperature and humidity sensor and finally the SH1107 OLED monitor to display the data. As well as a couple of STEMMA QT 100mm cables to connect all things together.

After connecting all the parts together I plug the QtPy to the computer and use Mu Editor to contact the board. You could use whatever client to edit the files you want, but it comes highly recommended to use the Mu Editor for CircuitPython.

The following is the code I put together to get the whole thing running.

import time
import board
import adafruit_sht4x
import busio
import displayio
import terminalio
from adafruit_display_text import bitmap_label as label
from adafruit_displayio_sh1107 import SH1107, DISPLAY_OFFSET_ADAFRUIT_128x128_OLED_5297


i2c = busio.I2C(board.SCL1, board.SDA1)
sht = adafruit_sht4x.SHT4x(i2c)
sht.mode = adafruit_sht4x.Mode.NOHEAT_HIGHPRECISION
display_bus = displayio.I2CDisplay(i2c, device_address=0x3D)

WIDTH = 128
HEIGHT = 128


display = SH1107(

while True:
    temperature, relative_humidity = sht.measurements
    # Make the display context
    splash = displayio.Group()

    # Draw some label text
    size_text = "%0.fc" % temperature;
    size_text_area = label.Label(
        terminalio.FONT, text=size_text, scale=3, color=0xFFFFFF, x=38, y=42
    oled_text = "%0.f%%" % relative_humidity;
    oled_text_area = label.Label(
        terminalio.FONT, text=oled_text, scale=3, color=0xFFFFFF, x=58, y=74

Then I added the necessary libraries into the lib directory of the RP2040.

Required libraries

As it is with these small controllers, when you save it reloads the file and runs it. So, if you have any issues they should be displayed in the serial part of Mu Editor.

Enclosure for the project

I’ve also drawn a 3D model of a small case for the project, here you can see the bottom half. There you can see how both the QtPy and the SHT40 sensor can be slotted in and the power for the QtPy comes in through that black box you see there on the left. I’ve even put drill holes for the screws to place this on the wall inside the bus. The 3D model is still a work in progress, but I think I’m getting closer to the end of the trial and error with the fit.

When it’s ready I will post it on my page on Thingiverse.

Here is at least a photo of everything working on my desk.

Running the working code

The only “problem” of sorts to mention is that because the OLED screen is connected via STEMMA QT, the refresh rate is slow.. deadly slow.

I notice that when the screen updates it blanks first and then loads the new values. So, I’m going to see if I can fix that somehow or if that is just a limitation I will have to live with.

1 thought on “A small Raspberry project”

  1. Pingback: Raspberry project – update –

Comments are closed.