Projects / Pi mini status screen

Pi mini status screen

A Raspberry Pi 4 shows its network address, processor temperature, load and memory on a small OLED, handy for a Pi on a shelf with no screen.

Beginner1.8 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. Pi 4

    Shut the Pi down

    Sudo shutdown now, then unplug power.

  2. Pi 4

    Wire the display

    Pin 1, pin 6, pin 3 and pin 5.

  3. Pi 4

    Boot and enable I2C

    sudo raspi-config nonint do_i2c 0.

  4. Pi 420.0 mASSD1306

    Install the library

    pip install luma.oled.

  5. Pi 4

    Check the bus

    i2cdetect -y 1 shows 3c.

  6. Pi 4

    Run the program

    Four lines appear.

  7. Pi 4

    Make it start at boot

    Add it to a systemd service or cron at reboot.

In short

How do you build a pi mini status screen?

A Raspberry Pi 4 shows its network address, processor temperature, load and memory on a small OLED, handy for a Pi on a shelf with no screen. You need Raspberry Pi 4 Model B (4 GB), SSD1306 OLED Display and Breadboard 830 Tie Points. It takes 7 steps and about 110 minutes.

Level
Beginner
Time
About 110 min
Parts
3

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
OLED VCCPi pin 1 (3.3 V)Power at 3.3 V
OLED GNDPi pin 6 (GND)Ground
OLED SDAPi pin 3 (GPIO2)I2C data
OLED SCLPi pin 5 (GPIO3)I2C clock

Code

A small screen turns a headless Pi into something you can read at a glance. The program draws four lines every three seconds. The network address comes from opening a datagram socket towards a made-up address, which sends nothing but makes the system pick the interface it would use, and then asking which local address it chose. The processor temperature is read from a file the kernel keeps up to date, in thousandths of a degree. The load is the average number of programs waiting to run, and memory use comes from the kernel memory table. A temperature above about 80 degrees means the Pi is throttling and needs better cooling. The OLED sits on the same two I2C pins as many other add-on boards, so you can add a clock chip or a sensor to the same wires later.

# Install first:  sudo raspi-config nonint do_i2c 0
#                  sudo apt install -y python3-pip python3-pil
#                  pip install luma.oled --break-system-packages   (or use a virtual environment)
import os, socket, time
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306

device = ssd1306(i2c(port=1, address=0x3C))

def cpu_temp():
    with open("/sys/class/thermal/thermal_zone0/temp") as f:
        return int(f.read()) / 1000.0

def ip_address():
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        s.connect(("10.255.255.255", 1))             # no packet is sent, this only picks the interface
        return s.getsockname()[0]
    except OSError:
        return "no network"
    finally:
        s.close()

def mem_used_percent():
    info = {}
    with open("/proc/meminfo") as f:
        for line in f:
            key, value = line.split(":")
            info[key] = int(value.split()[0])
    return 100 * (1 - info["MemAvailable"] / info["MemTotal"])

while True:
    load1 = os.getloadavg()[0]
    with canvas(device) as draw:
        draw.text((0, 0), "IP " + ip_address(), fill="white")
        draw.text((0, 16), "CPU temp {:.1f} C".format(cpu_temp()), fill="white")
        draw.text((0, 32), "Load {:.2f}".format(load1), fill="white")
        draw.text((0, 48), "Memory {:.0f} %".format(mem_used_percent()), fill="white")
    time.sleep(3)

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
After startIP address, temperature, load and memory
Run a heavy taskLoad and temperature rise
Unplug the network cableShows no network
RebootStarts again if set to run at boot
Compared with the terminalValues match vcgencmd measure_temp

If it does not work

Blank screen

Check I2C is on and i2cdetect shows address 3c.

ModuleNotFoundError

Install luma.oled for the same Python you run.

Permission error

Add your user to the i2c group or run with sudo.

Wrong characters

The default font is small, keep text short.

No network shown

Connect Wi-Fi or Ethernet first.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the pi mini status screen?

Raspberry Pi 4 Model B (4 GB), SSD1306 OLED Display and Breadboard 830 Tie Points.

How long does the pi mini status screen take to build?

About 110 minutes for a beginner maker, in 7 steps.

How do I know the pi mini status screen works?

After start: IP address, temperature, load and memory. Run a heavy task: Load and temperature rise. Unplug the network cable: Shows no network.

Blank screen: what should I check?

Check I2C is on and i2cdetect shows address 3c.

ModuleNotFoundError: what should I check?

Install luma.oled for the same Python you run.

Permission error: what should I check?

Add your user to the i2c group or run with sudo.

Wrong characters: what should I check?

The default font is small, keep text short.