# OLED spectrum display on Volumio on Raspberry Pi Zero W

**URL:** <https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067>\
**Category:** Diy and Tweaks\
**Created:** [March 9, 2018, 8:19pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067 "2018-03-09T20:19:18Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Adrii](https://community.volumio.com/user_avatar/community.volumio.com/adrii/32/502_2.png) [@Adrii](https://community.volumio.com/u/Adrii)\
**Post date:** [April 9, 2018, 6:30pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/21 "2018-04-09T18:30:14Z")

</div>

I was unable to reproduce the error, but reviewing the code I found a mistake in a check for a valid integer. I have pushed a fix for this. Hopefully it will clear the error you are seeing.

The value that is meant to be an integer is the volume value from the Volumio status. If you are able to retrigger the error, I would be interested to see the Volumio status from following command

```auto
curl http://localhost:3000/api/v1/getstate
```

Thanks

Adrian.

---

<div class="post-metadata">

**Author:** ![profd](https://community.volumio.com/letter_avatar_proxy/v4/letter/p/df788c/32.png) [@profd](https://community.volumio.com/u/profd)\
**Post date:** [April 9, 2018, 8:01pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/22 "2018-04-09T20:01:53Z")

</div>

Thank Your.  
Now its work fine !

---

<div class="post-metadata">

**Author:** ![Adrii](https://community.volumio.com/user_avatar/community.volumio.com/adrii/32/502_2.png) [@Adrii](https://community.volumio.com/u/Adrii)\
**Post date:** [May 4, 2018, 3:46pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/23 "2018-05-04T15:46:33Z")

</div>

I have made the OLED display program compatible with other players, and renamed it to mpd\_oled. The project location is now

[github.com/antiprism/mpd\_oled](https://github.com/antiprism/mpd_oled)

Adrian.

---

<div class="post-metadata">

**Author:** ![Josh2000](https://community.volumio.com/user_avatar/community.volumio.com/josh2000/32/347_2.png) [@Josh2000](https://community.volumio.com/u/Josh2000)\
**Post date:** [May 5, 2018, 6:03pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/24 "2018-05-05T18:03:44Z")

</div>

Hi Adrian,

I installed it uncountable times now, each time on a fresh system, different RasPI’s - today i gave the updated system a try.  
It is working as expected - the only problem that still comes up is - after about 2 to 4 hours running the display freezes.

I created a cron job that runs every 90 minutes and doing a restart of the display…

`sudo systemctl stop mpd_oled
sudo systemctl start mpd_oled`  
but i think this is not the “golden” solution… 😉

Is there any specific log i could have a look at - or send it to you, that could explain the hog up ?

* * *

Another thing:

90% the title is too long to be displayed completely and is cut in the second line.  
I guess it could be doable somehow to let this line scroll to show the whole title This would be really great.

Where do i find the screen configuration ?

Thank you for this excellent work - it is really looking great.

- Josef

---

<div class="post-metadata">

**Author:** ![Adrii](https://community.volumio.com/user_avatar/community.volumio.com/adrii/32/502_2.png) [@Adrii](https://community.volumio.com/u/Adrii)\
**Post date:** [May 5, 2018, 8:20pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/25 "2018-05-05T20:20:28Z")

</div>

Hi Josef

I am pleased it is largely working for you!

I am not sure what is causing the freeze. I have been running the latest mpd\_oled code on the latest Volumio since yesterday, and playing some music now the display is working correctly, but I haven’t been playing a lot of music today. I’ll run it for a while playing music tomorrow. I got a second OLED on Thursday and have just set up another player so I will try it with Volumio on that too.

To troubleshoot, when the display is frozen you could: run `top` and see whether mpd\_oled and cava are running, run `ls /tmp` and see if you can see the FIFOs mpd\_oled\_fifo and cava\_fifo, you could look at the logs `less /var/log/volumio.log` and `dmesg | less’.

Is it a complete screen freeze, or just the spectrum analyser?

I am not sure what you mean by screen configuration. `mpd_oled -h` will print the command line options. Or if you want to change the layout, the function that draws all the screen elements is draw\_spect\_display in main.cpp. The screen elements are like widgets and so it is possible to create alternative screen layouts by modifying this function. I might provide an option for some different layouts. The text widget doesn’t currently support scrolling (I had scrolling on an LCD display and didn’t like it!) but I can look at adding it in, with an option for the scroll speed.

Adrian.

---

<div class="post-metadata">

**Author:** ![Adrii](https://community.volumio.com/user_avatar/community.volumio.com/adrii/32/502_2.png) [@Adrii](https://community.volumio.com/u/Adrii)\
**Post date:** [May 6, 2018, 3:34pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/26 "2018-05-06T15:34:48Z")

</div>

Hi Josef

In testing today, one of the displays froze after eleven hours of playing music. There is nothing of interest in the logs. The freeze is because mpd\_oled is no longer running. The most likely explanation is that it has crashed. I will run it from the command line next and see if there is any error message when it stops.

Adrian.

---

<div class="post-metadata">

**Author:** ![Adrii](https://community.volumio.com/user_avatar/community.volumio.com/adrii/32/502_2.png) [@Adrii](https://community.volumio.com/u/Adrii)\
**Post date:** [May 7, 2018, 9:09am UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/27 "2018-05-07T09:09:56Z")

</div>

I ran mpd\_oled from the command line, and it ran for 18 hours before stopping. Unfortunately there was no error message. I’ll carry out a general review of the code next.

---

<div class="post-metadata">

**Author:** ![Adrii](https://community.volumio.com/user_avatar/community.volumio.com/adrii/32/502_2.png) [@Adrii](https://community.volumio.com/u/Adrii)\
**Post date:** [May 9, 2018, 7:27am UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/28 "2018-05-09T07:27:53Z")

</div>

Quick update. I added some extra error handling but the program still failed. I did however see a crash error message relating to incorrect use of dynamically allocated memory.

I reviewed the program code carefully for this, but couldn’t spot an error. I therefore ran mpd\_oled in an environment that monitors memory access (valgrind) to see where the problem was occurring. However, 24 hours of playing music later and the program is still running and there are no messages.

In another test I have been running mpd\_oled on Moode while playing music. It has now been running 48 hours without any problems.

In a current test, it is possible to specify a replacement memory allocation implementation that is “safer” (works around programming errors) and can also warn about incorrect memory use. I am not seeing any immediate errors with it. I will leave it running to see if the program still stops when using it.

```auto
MALLOC_CHECK_=1 sudo ./mpd_oled -o 6 -b 21 -f 25
```

I will also look at compiling mpd\_oled with -fsanitize, which will provide extra diagnostic messages. I will also check if the program fails when it is built with Clang rather than GCC.

---

<div class="post-metadata">

**Author:** ![Josh2000](https://community.volumio.com/user_avatar/community.volumio.com/josh2000/32/347_2.png) [@Josh2000](https://community.volumio.com/u/Josh2000)\
**Post date:** [May 9, 2018, 5:22pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/29 "2018-05-09T17:22:24Z")

</div>

Hi Adrian,

I’m happy you are working on the stability as i like it really a lot.

I’m just testing marco79cgn’s 1st version of his “Radio Paradise” plugin, that is working good so far.  
Can you imagine why the station and title isn’t passed to the display. (May be this is out of scope currently - but could be you have an idea)  
Where do i find the display config ?

Thank you

Josef

---

<div class="post-metadata">

**Author:** ![Josh2000](https://community.volumio.com/user_avatar/community.volumio.com/josh2000/32/347_2.png) [@Josh2000](https://community.volumio.com/u/Josh2000)\
**Post date:** [May 9, 2018, 5:56pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/30 "2018-05-09T17:56:12Z")

</div>

Hi Adrian,

me again… I know working on the stability is currently for sure the most important thing.

Just another thing (why i asked for where to find the display config):  
The bitrate display seems to be limited to 3 characters while there would be enough space to show a 4th character.  
If you play flac this leads to end with 999 if the bitrate gets over 1000kBps.

Also i forget to paste the direct link to Marco’s “Radio Paradise Plugin”:  
[https://volumio.org/forum/radio-paradise-t9886.html#p48639](https://volumio.org/forum/radio-paradise-t9886.html#p48639)

Josef

---

<div class="post-metadata">

**Author:** ![Adrii](https://community.volumio.com/user_avatar/community.volumio.com/adrii/32/502_2.png) [@Adrii](https://community.volumio.com/u/Adrii)\
**Post date:** [May 9, 2018, 7:16pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/31 "2018-05-09T19:16:44Z")

</div>

Hi Josef

I can add an extra digit for the kbitrate.

The reason for the missing information with the Radio Paradiso plugin is that it is not available to MPD. Compare the output of the Volumio and MPD status commands

`volumio@volumio3:~/proj/mpd_oled$ volumio status
{
  "status": "play",
  "position": 1,
  "title": "The Wailin' Jennys - Arlington",
  "artist": "The Wailin' Jennys",
  "album": "40 Days",
  "albumart": "http://img.radioparadise.com/covers/l/B0002IQGMQ.jpg",
  "uri": "https://apps.radioparadise.com/blocks/chan/0/4/1687836-1687837.flac?src=alexa",
  "trackType": "flac",
  "seek": 150715,
  "duration": 281,
  "samplerate": "44.1 KHz",
  "bitdepth": "16 bit",
  "channels": 2,
  "random": null,
  "repeat": null,
  "repeatSingle": false,
  "consume": false,
  "volume": 20,
  "mute": false,
  "stream": "flac",
  "volatile": false,
  "service": "radio_paradise"
}
`

`volumio@volumio3:~/proj/mpd_oled$ mpc status
https://apps.radioparadise.com/blocks/chan/0/4/1696274-1696277.flac?src=alexa
[playing] #1/1 6:39/14:02 (47%)
volume: 40% repeat: off random: off single: off consume: on 
`  
I can read the Volumio status, and currently use the volume value from it. However, it is very slow to get a status update when a track changes, generally taking around 7 seconds. The MPD status is always returned quickly, but you can see above that besides the missing titles, it also has a different track length/progress. Maybe the Volumio status slowness is only a Pi Zero issue, and it is quick enough on a regular Pi (I don’t have one to test on). I posted about it here  
[determine-current-volume-from-t9493.html#p47431](https://volumio.org/forum/determine-current-volume-from-t9493.html#p47431)  
It makes sense to add the Volumio status values back in as an alternative to the MPD values when running on Volumio.

I am currently 10 hours in to tests of the alternative malloc on one machine, and the Clang build on another. Hopefully both displays will still be running in the morning!

Adrian.

---

<div class="post-metadata">

**Author:** ![Adrii](https://community.volumio.com/user_avatar/community.volumio.com/adrii/32/502_2.png) [@Adrii](https://community.volumio.com/u/Adrii)\
**Post date:** [May 9, 2018, 8:27pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/32 "2018-05-09T20:27:58Z")

</div>

Just to note that, testing again now on the latest Volumio the Volumio status response is improved. I can run ‘volumio volume’ repeatedly around 2-4 times per second, and when changing track there are delays ranging 1-4 seconds over around a 10 second period.

You can see the delays by running this command and changing tracks in the Volumio UI (CTRL-C to stop it).

```auto
while true; do volumio volume; date; done
```

Adrian.

---

<div class="post-metadata">

**Author:** ![Josh2000](https://community.volumio.com/user_avatar/community.volumio.com/josh2000/32/347_2.png) [@Josh2000](https://community.volumio.com/u/Josh2000)\
**Post date:** [May 10, 2018, 7:50am UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/33 "2018-05-10T07:50:49Z")

</div>

Hi Adrian,

I understand. Thank you.  
I’m on vacation for some days now and will have a deeper look into it next week.

Josef

---

<div class="post-metadata">

**Author:** ![Adrii](https://community.volumio.com/user_avatar/community.volumio.com/adrii/32/502_2.png) [@Adrii](https://community.volumio.com/u/Adrii)\
**Post date:** [May 13, 2018, 8:44am UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/34 "2018-05-13T08:44:01Z")

</div>

Hi Josef

I believe I have found and fixed the bug that was causing the screen to freeze after several hours. With the fix applied, I have been able to play music continuously for 48 hours without any kind of issue.

I also changed to using Volumio status values (when running on on Volumio), which now makes the display compatible with the Radio Paradise plugin. I also added support for the full display of kbitrates with up to 4 digits.

I have uploaded the changes to Github.

Adrian.

---

<div class="post-metadata">

**Author:** ![Josh2000](https://community.volumio.com/user_avatar/community.volumio.com/josh2000/32/347_2.png) [@Josh2000](https://community.volumio.com/u/Josh2000)\
**Post date:** [May 15, 2018, 5:59pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/35 "2018-05-15T17:59:35Z")

</div>

Hi Adrian,

Thank you - it is running stable now for more than 22 hours.  
And thank you for adding the 4th digit to the bitrate.

i already posted to Marco’s “Radio Pardise” topic because i’m not sure who of you both could fix this:

## What i see on the display is:

## Interpret Interpret - title

… where i see the interpret twice what doesn’t make much sense IMHO  
should be:

* * *

## Radio Paradise Interpret - title

- Josef

---

<div class="post-metadata">

**Author:** ![Adrii](https://community.volumio.com/user_avatar/community.volumio.com/adrii/32/502_2.png) [@Adrii](https://community.volumio.com/u/Adrii)\
**Post date:** [May 17, 2018, 8:26am UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/36 "2018-05-17T08:26:49Z")

</div>

Hi Josef

Marco has put the radio station name as the artist, available in the plugin Github code, which fixes this issue. When I tested I simply overwrote a plugin file, so if you grabbed a zip of the plugin it might not have been be included in the latest zip at that time.

Adrian.

---

<div class="post-metadata">

**Author:** ![Adrii](https://community.volumio.com/user_avatar/community.volumio.com/adrii/32/502_2.png) [@Adrii](https://community.volumio.com/u/Adrii)\
**Post date:** [May 17, 2018, 10:34am UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/37 "2018-05-17T10:34:52Z")

</div>

Hi Josef

I uninstalled the old version of the Radio Paradis plugin, and installed the new official version. The artist is reported by ‘volumio status’ (and displayed on the OLED) as “Radio Paradise”

`"title": "Ennio Morricone - The Good, The Bad & The Ugly",
"artist": "Radio Paradise",
"album": "An Hour with Ennio Morricone",
...
"service": "radio_paradise"`

Adrian.

---

<div class="post-metadata">

**Author:** ![Josh2000](https://community.volumio.com/user_avatar/community.volumio.com/josh2000/32/347_2.png) [@Josh2000](https://community.volumio.com/u/Josh2000)\
**Post date:** [May 17, 2018, 5:02pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/38 "2018-05-17T17:02:35Z")

</div>

Hi Adrian,

Yes - it’s working and it’s working really stable now for more than 3 days !!! 😃  
Also the title and radio station issue with the Radio Paradise plugin is fixed. (Has been an error by me) Thank you and Marco.

The only thing i would wish now is a scrolling “Artist - Title” line as this is nearly always cut off on the small display.  
Do you think this would be doable in the future ?

* * *

Also i have the “dream” of putting 2 of these displays in line and span the text. (Maybe using the rest of the second display to show other data - temperature, alarm clock time, date, weather forecast, left and right channel of the spectrum analyser separated or whatever…)

I had a closer look at the display (i also own some of the cheap 4 pin SD1106 version types) and found one can change the I2C address by changing a 0-ohm resistor on the back side of these.

## I wished i had more time to improve my own coding skills to be more helpful instead of only offering my “dreams”…

Anyway i’m more than happy with what i have now.

Maybe some day there also will be found a volumio developer that is able to build a real plugin around that to make it available to the rest of the community. It’s really looking awesome.

Thank you again for all that effort. Don’t think there are many out there that are able to fix those stability issues the way you did.

- Josef

---

<div class="post-metadata">

**Author:** ![Adrii](https://community.volumio.com/user_avatar/community.volumio.com/adrii/32/502_2.png) [@Adrii](https://community.volumio.com/u/Adrii)\
**Post date:** [June 27, 2018, 1:02pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/39 "2018-06-27T13:02:24Z")

</div>

Hi Josef

I haven’t forgotten your request! I have just pushed some changes that add scrolling for the station/artist and title fields.

I have implemented the scrolling as: start with a delay, then scroll continuously, adding five spaces between the end of the text before the beginning appears again at the right. The scrolling rate and delay can be specified with option -s. The scrolling rate might be close to the frame rate, and this unfortunately affects affects the smoothness of the scrolling.

There are quite a lot of other changes relating to option processing and reporting generally, and I also changed the timing code to allow more screen updates in the paused state, so it is possible there might be some issues.

I also recently added clearing the screen on shutdown.

Adrian.

---

<div class="post-metadata">

**Author:** ![Josh2000](https://community.volumio.com/user_avatar/community.volumio.com/josh2000/32/347_2.png) [@Josh2000](https://community.volumio.com/u/Josh2000)\
**Post date:** [June 27, 2018, 5:38pm UTC](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067/40 "2018-06-27T17:38:22Z")

</div>

Hi Adrian,

That’s really fantastic news. Thank you so much. 🙂🙂🙂🙂🙂

I will immediately update and test. What value would you recommend for setting the -s parameter if i use an update rate of e.g 20 ?

- didn’t find an update in the docu regarding that.

Josef

[Previous page](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067.md?page=1)

[Next page](https://community.volumio.com/t/oled-spectrum-display-on-volumio-on-raspberry-pi-zero-w/8067.md?page=3)
