My little all in one volumio box

Hey,

recently i finished my first volumio wlan box. it will be used to power up some very old BOSE 2.1 Speaker in my bedroom.

The box contains one Raspi B with an Audiophonics DAC Sabre ES9023. The DAC is directly connected to a 2*50W Class D amplifier /This one: store.sure-electronics.com/audio … aa-ab32174 ). To connect the Speakers to the amplifier i use a regular terminal connector block

To hold all this stuff i designed some easy clamps, which are glued to the bottom plate of the acrylic glas case. The clamps are printed on my 3d printer in ABS plastics.

The Power source is a universal DC power supply with 15-24V and 5,5A. In order to power up the amplifier with 24v and the raspberry with 5v i added a dc-dc converter as a voltage regulator for the raspberry.
IMG_20150103_114703.jpg

Also i added a 16x2 LCD to the front panel of my small box. Its connect via i2c to the pi. I’ve found a lib written in python to use the display. Also i wrote a small bash script to collect the informations i want to show on the LCD

The scripts uses mpc to readout the current song. If there is no song playing it shows the ip-address of eth0 in line one and wlan0 in line two.
IMG_20150103_114838.jpg
IMG_20150103_115824.jpg

I will replace the black painted (i’m not good in painting stuff) mdf front panel trough a laser cut black acrylic glas panel as soon as the lasercutter in my fablab is up and running.

Hi!
Well done!
Could you give us please dc-dc regulator that you use ?
As it has been explain in a other thread, you should get i2C wire as short as possible. (I have got the same dac)
For the lcd script could give some info / source ( I’m looking one for a new project)

i don’t have any sound issues so i dont so a reason to short that cable.

i use this step down converter

this is my display
and this Adapter

You can find the python lib for the lcd under extremeelectronics.co.uk/blo … pberry-pi/

To work with the lib i wrote two small tools:

lcd.py (place it in the same directory as th pylcdlib:

import pylcdlib, sys, getopt
lineone = ''
linetwo = ''

def main(argv):
   try:
      opts, args = getopt.getopt(argv,"hf:s:",["lone=","ltwo="])
   except getopt.GetoptError:
      print 'lcd.py -f <zeile1> -s <zeile2>'
      sys.exit(2)
   for opt, arg in opts:
      if opt == '-h':
         print 'lcd.py -f <zeile1> -s <zeile2>'
         sys.exit()
      elif opt in ("-f", "--lone"):
         global lineone
         lineone = arg
      elif opt in ("-s", "--ltwo"):
         global linetwo
         linetwo = arg
if __name__ == "__main__":
   main(sys.argv[1:])

lcd = pylcdlib.lcd(0x3f,1) # define the i2c adress of your display
lcd.lcd_write(0x01);
lcd.lcd_puts(str(lineone),1)
lcd.lcd_puts(str(linetwo),2)
lcd.lcd_backlight(1)

you need to set the i2c address of the display in this script. after this you can use the script with the parameters -f and -s (for first and second line)
for example:

python lcd.py -f "Rise Against" -s "I Dont want to be here anymore"

The other script to detect the ip-addresses and whats playing is this bash script:

[code]#!/bin/bash

while true
do
LASTSONG=$(cat /root/lastsong.txt)
ARTISTIN=$(mpc -f “%artist%” | head -1)
TITLEIN=$(mpc -f “%title%” | head -1)
ARTIST=$(echo ${ARTISTIN} | sed “s/[’’]//g”)
TITLE=$(echo ${TITLEIN} | sed “s/[’’]//g”)
CURRENTSONG="$ARTIST - $TITLE"
if [[ $ARTIST == “volume:” ]]
then
IP_eth=$(ifconfig eth0 | grep “inet addr:” | awk ‘{print $2}’ | cut -f2 -d’:’)
IP_wlan=$(ifconfig wlan0 | grep “inet addr:” | awk ‘{print $2}’ | cut -f2 -d’:’)
python /root/lcd/lcd.py -f “$IP_eth” -s “$IP_wlan”
elif [ “$CURRENTSONG” != “$LASTSONG” ]
then
echo “$CURRENTSONG” > /root/lastsong.txt
python /root/lcd/lcd.py -f “$ARTIST” -s “$TITLE”
fi
sleep 5
done[/code]

This script is added to the rc.local like this:

/root/lcd.sh & > /dev/null 2>&1

so its started into background on startup and runs in an endless loop.

To use the python lib you need to install a few tools:

sudo apt-get install python-smbus i2c-tools

And you have to load some kernel modules

modprobe i2c-bcm2708 modprobe i2c-dev

The best solution would be to add the modules i2c-bcm2708 and i2c-dev to your /etc/modules

Hi!
Thank you very much for all details you gave. Few days ago, I have ordered a LCD http://www.amazon.fr/gp/product/B00AT8KGF2?psc=1&redirect=true&ref_=oh_aui_detailpage_o08_s00 and a I2c http://www.amazon.fr/gp/product/B00GBSWOWW?psc=1&redirect=true&ref_=oh_aui_detailpage_o02_s00. It seems to be the same than yours. I waiting to recieve my order and test it !!! :smiley:

yep looks identical and this should work with my script and the pylcdlib.

Hi - a very nice project, I will definitely try something similar. One question, how do you power the system up and down? I mean have you included any physical buttons etc. If yes, what is your solution?

i use the shutdown button in the volumio webinterface and after its shutdown, i cut the power connection with a built in switch on the back.

If you want a more safe method: you can built a more intelligent switch based on an arduino (the pro mini version for 2-3$ should be enough) and an backup battery. The arduino watches if there is a input voltage if no: it will send a signal to one of the gpio pins of the pi. A script on the pi will read from the gpio pin and if there is a signal on the pin, it will send a shutdown -h now command.

while the external power source is shutdown, the pi and the arduino are powered by the backup battery like a small Uninterruptible Power Supply

@KSE
Nice box and a creative software solution!

By the way instead of polling the songinfo and save this to a file to compare this with the currentinfo, you could use “mpc idle”
In this case the subsystem player. So when something changes regarding the player this event will trigger an update of the song info.

[code]#! /bin/sh
while : ; do
mpc idle player >/dev/null
(
mpc current -f “[[[%artist% - ]|[%name%: ]]&[%title%]]|[%title%[%name%]]”
)

done[/code]

Syntaxis:

-f,–format

Configure the format of song display for status and the playlist. The metadata delimiters are "%name%", "%artist%", "%album%", "%title%", "%track%", "%time%", and "%file%". The [] operator is used to group output such that if no metadata delimiters are found or matched between '[' and ']', then none of the characters between '[' and ']' are output. '&' and '|' are logical operators for and and or. '#' is used to escape characters. Some useful examples for format are: "%file%" and "[[%artist% - ]%title%]|[%file%]". This command also takes the following defined escape sequences:
\\ - backslash
\a - alert
\b - backspace
\t - tab
\n - newline
\v - vertical tab
\f - form-feed
\r - carriage return 

I use this syntax because it works fine with MP3-files (Artist - Title) and Radiostations which provides different fields (Name+Title or Name or Title) and it results in one line.

I would like to embed the “mpc idle” command in a python-script but I dont know how to write an event!