[PLUGIN] MPD OLED - installation & configuration plugin

Hi, I would like to know if I can simultaneously add an oled static display with values ​​of cpu, temperature, wifi, etc. to Volumio for Raspberry pi 4B. Thanks for the info and help, I’m starting with RPI thanks

Why, why, why you want to see all this on music “player”? Volume, bitrate, album, song, track I understand, but values of cpu?

On the main panel, only the song, artist, etc. On another small OLED display, these system values.

You can never have too much data

1 Like

Yes, you can do this! Here’s how

  1. Go to GitHub - antiprism/mpd_oled: MPD, Volumio, RuneAudio and Moode OLED status and spectrum display for Raspberry Pi (and similar) and download the source code
  2. Make your changes to the code
  3. Build
  4. Copy mpd_oled to /usr/bin/mpd_oled
  5. Restart the plugin

Install the plugin first and then go into the plugin settings, click on the I2C OLED wiring button and then attach the screen as per instructions. Once completed try the different screen types, one of them will definitely work.

Ok, will the oled show wifi, cpu, temperature? thanks for the help

The oled can display anything you like! Do you have any C++ experience?

here is a scribble in Python I’ve played with many moons ago. It’s just as starter. it’s untested and not supported by me:

import busio
import adafruit_ssd1306
import gpiozero as gz
import time
import psutil
import socket
import netifaces as ni

from board import SCL, SDA
from PIL import Image, ImageDraw, ImageFont

# Create the I2C interface.
i2c = busio.I2C(SCL, SDA)

# Create the SSD1306 OLED class.
# The first two parameters are the pixel width and pixel height.
disp = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)

# Clear display.
disp.fill(0)
disp.show()

# Create blank image for drawing.
# Make sure to create image with mode '1' for 1-bit color.
width = disp.width
height = disp.height
img = Image.new("1", (width, height))

# Get drawing object to draw on image.
draw = ImageDraw.Draw(img)

# Load fonts.
fonta = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 10)
fontb = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 12)
fontc = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 14)
fontd = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 16)
fonte = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 18)
fontf = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 20)
fontg = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 22)
fonth = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 24)
fonti = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 26)
fontj = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 28)
fontk = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 30)
fontl = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 32)
fontm = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 34)
fontn = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 36)
fonto = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 38)
fontp = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 40)

def get_size(bytes, suffix="B"):
    """
    Scale bytes to its proper format
    e.g:
        1253656 => '1.20MB'
        1253656678 => '1.17GB'
    """
    factor = 1024
    for unit in ["", "K", "M", "G", "T", "P"]:
        if bytes < factor:
            return f"{bytes:.2f}{unit}{suffix}"
        bytes /= factor
		
def cputemp():
	cmd = gz.CPUTemperature().temperature
	result = str('{0:.1f}'.format(cmd))
	return result
	
def cpuload():
	cmd = psutil.cpu_percent()
	return str('{:.1f}'.format(cmd)).zfill(4)
	
def getip(interface):
	ni.ifaddresses(interface)
	ip = ni.ifaddresses(interface)[ni.AF_INET][0]['addr']
	return ip
	
def gethostname():
	hostname = socket.gethostname()
	return hostname	
	
def bytes_sent():
	net_io = psutil.net_io_counters()
	return get_size(net_io.bytes_sent)
	
def bytes_received():
	net_io = psutil.net_io_counters()
	return get_size(net_io.bytes_recv)

def bytesread():
	disk_io = psutil.disk_io_counters()
	return get_size(disk_io.read_bytes)
	
def byteswritten():
	disk_io = psutil.disk_io_counters()
	return get_size(disk_io.write_bytes)

def memtotal():
	svmem = psutil.virtual_memory()
	return get_size(svmem.total)
	
def memuavailable():
	svmem = psutil.virtual_memory()
	return get_size(svmem.available)
	
def memperc():
	svmem = psutil.virtual_memory()
	return str(svmem.percent) + " %"

draw.text(( 0,  0), "CPU:" , font=fontb, fill=255)   
draw.text((  40, 0), cputemp()   , font=fontk, fill=255)
draw.text((115, 0), "°"         , font=fontk, fill=255)

draw.text((  30, 32), cpuload()   , font=fontk, fill=255)
draw.text((110, 40), "%"         , font=fontd, fill=255)

disp.image(img)
disp.show()

time.sleep(6)
img = Image.new("1", (width, height))
draw = ImageDraw.Draw(img)

draw.text(( 0,  0), "Network IP:" , font=fontb, fill=255) 
draw.text((  0, 17), gethostname()   , font=fontc, fill=255)
draw.text((  0, 34), getip('eth0') + "-W"  , font=fontb, fill=255)
draw.text((  0, 51), getip('wlan0') + "-WL"   , font=fontb, fill=255)

disp.image(img)
disp.show()

time.sleep(6)

img = Image.new("1", (width, height))
draw = ImageDraw.Draw(img)

draw.text(( 0,  0), "Network data: " , font=fontb, fill=255) 
draw.text((  0, 20), "o: " + bytes_sent()   , font=fontc, fill=255)
draw.text((  0, 40), "i: " + bytes_received()   , font=fontc, fill=255)

disp.image(img)
disp.show()

time.sleep(6)

img = Image.new("1", (width, height))
draw = ImageDraw.Draw(img)

draw.text(( 0,  0), "Disk data: " , font=fontb, fill=255) 
draw.text((  0, 20), "w: " + byteswritten()   , font=fontc, fill=255)
draw.text((  0, 40), "r: " + bytesread()   , font=fontc, fill=255)

disp.image(img)
disp.show()

time.sleep(6)

img = Image.new("1", (width, height))
draw = ImageDraw.Draw(img)

draw.text(( 0,  0), "Memory:" , font=fontb, fill=255) 
draw.text((  0, 17), "t: " +  memtotal()   , font=fontc, fill=255)
draw.text((  0, 34), "a: " + memuavailable()  , font=fontb, fill=255)
draw.text((  0, 51), "p: " + memperc()  , font=fontb, fill=255)

disp.image(img)
disp.show()

time.sleep(5)
1 Like

I’m a beginner learning

1 Like

Hi guys, I have an issue with this plugin.

I installed it fine and works as expected, the problem comes when I restart the system.

It starts fine and screen comes on and shows time etc., but when I try to play music it comes up with this error
image

If I disable the plugin, restart the device and then enable the plugin again, then it’s fine

Can you try to disable startup sound and /or mutliroom playback

1 Like

Thank you, disabling the startup sound fixed it