Third party cookies may be stored when visiting this site. Please see the cookie information.

PenguinTutor YouTube Channel

Raspberry Pi Pico Temperature Sensor using I2C and OLED display

How to use a Raspberry Pi Pico as a temperature display. This uses a tiny 0.9 inch OLED display with a AM2320 temperature sensor.

Raspberry Pi Pico vs. Pimoroni Tiny 2040

In this case I’ve used a different variant of the Pico which is the Tiny 2040 from Pimoroni. This is based around the same microcontroller, which is the RP2040 created by Raspberry Pi.

Raspberry Pi Pico Temperature Display project

There are a few differences between the Tiny2040 and the Raspberry Pi Pico. The first most obvious is the size. The TINy 2040 has been designed to be as small as possible. It has only 8 digital pins and 4 analog pins. Along with the power pins this gives a total of 16 pins (excluding the debug pins). It’s also narrower, if you are using a breadboard then it gives you one extra row of pins.

They’ve replaced the single colour LED with a 3 colour LED, note that this is just an LED, it’s not a NeoPixel which they use on some of their add-on boards. The tiny 2040 uses a USB-C connector instead of a micro-USB connector used on the Pico.

The Tiny2040 is more expensive than the Pico. Where size is important then the Tiny2040 is likely a good fit, but otherwise you may be better with the cheaper Raspberry Pi Pico.

I2C

The temperature sensor and OLED display both use I2C. This allows multiple devices to be connected to a single-bus using only 2-wires (plus power supply and ground).

For more details of how I2C works see Electronics guide to I2C between Raspberry Pi, Arduino and Raspberry Pi Pico.

Temperature Sensor - AM2320

The temperatures sensor I using here is the AM2320. This is similar in appearance to the DHT11 which I have used in previous projects. The AM2320 can use a single-wire interface like the DHT11 uses, but it also includes support for I-squared-c which is what I used.

0.91" OLED Display (SSD1306)

To display the output I’ll be using a tiny 0.91 inch OLED screen (SSD1306).

This is a tiny monochrome screen with a easy to read display which can display text or monochrome graphics. The screen has a resolution of 128 x 32 pixels. I actually bought this to create a departure sign for a model railway, but I thought it made a good fit for this circuit as well.

Software download

The code is available to download below.

Other libraries referenced include:

Previous Raspberry Pi and Arduino communications
Raspberry Pi and Arduino communications
Next Model Railway Capacitor Discharge Unit (CDU)
Model Railway Capacitor Discharge Unit (CDU)