INTERACT FORUM

More => Old Versions => JRiver Media Center 20 for Linux => Topic started by: Hilton on March 12, 2015, 07:40:04 am

Title: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on March 12, 2015, 07:40:04 am
The mad professor has been at work again. :)

I managed to get a portable MC20 server running on a Pi2 with 500GB 2TB HDD and about 6-8hrs battery life in a small tidy little box.
I call it the Pi "Brick" Media Center.  

I'll be finishing it on the weekend and tidying it up a bit. I'll take to the case with the Dremel to fit external ports, leds. power etc.
Pics and video of assembly and demo below. :)


(https://ukqqpw.dm2301.livefilestore.com/y2pc-p9GkCrH_iktXd4wck34barRV0EQL5dU6001sDZI9R8I4XheeVe8PPGdxamqxdE68OX7XNDvP-025RBJY49H0oIuXEOmYE-VVdUwIDut2Q7wiVrFDf7Q9e76uSwpj2yc2yFUEH2CBpiGkAQtXEPMA/Pi-brick4.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2ppGYlgrygqOq7_3j8B4xLKvs8PD1i4U-TLtQ7whsKI77ZIdSwTV_KqMGmxVkceUb5S-FuWZMBPxHMvKcJ2DmrUmTdokwpuyI2E4v7aBlErVPcka5h0zqkHteNnLtaeW1-f4d8G65TxJFDxwn2fEb3LA/Pi-brick1.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2p_B3EFlEEWx_Ic3cqgfHr8vzAJfswlYODWcMJwdZur8l0EEeIXqC1dOj2sTDw6aAj_79ZWbg6OzgN1b4WjJ1VMELpqUSzLpK6usz51y3T8k3MaNyaI6CnjMe54Ug4-lnl_WWRHnIv0bizhYt9mHWZXQ/Pi-brick2.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2pSHVzelNBCa1L4PRNJE2qrGgg35QIvcN2m0JwYnsVTK5S5wNJhvrKVMMWjDS5h3psX3K95qN9hPSjjtDpaSNZyRgMmuGFSf6Wb4athOzj8WgZGFOb7sb5ogCPJ44-Tcyo9RDY8muB-jziONraBRC-FQ/Pi-brick3.jpg?psid=1)


Here's the complete youtube playlist for the Pi2 Brick MC20. I'll update this as I make further developments.
<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=PLidW7ho7KcuCxXGSU0l_5MV6w4shFxIYn" frameborder="0" allowfullscreen></iframe>


Part 1 Video
<iframe width="560" height="315" src="https://www.youtube.com/embed/bM5nhlm_Y4M" frameborder="0" allowfullscreen></iframe>
https://www.youtube.com/watch?v=bM5nhlm_Y4M

Part 2 Video
<iframe width="560" height="315" src="https://www.youtube.com/embed/xtzarC_IqyQ" frameborder="0" allowfullscreen></iframe>
https://www.youtube.com/watch?v=xtzarC_IqyQ

Part 3 Video
<iframe width="560" height="315" src="https://www.youtube.com/embed/KlYi4SwEmfc" frameborder="0" allowfullscreen></iframe>
https://www.youtube.com/watch?v=KlYi4SwEmfc



Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 13, 2015, 12:51:52 pm
I think you're gonna love this!

I got the Pi2 to do a few things with the GPIO3 pin to manage MC20 in headless mode.

I can restart MC20, Reboot or shutdown all with a momentary button attached to GPIO3.

I have a timer setup to measure the button press time to execute the various commands.

It's a heavily modified GPIO actions script.
I'll also be setting up a hard reset button too with the "Run" pins.
So in headless mode I'll have a few options to reset or power off gracefully.

The Pi can corrupt the SD card if you don't shutdown gracefully so it's important to have some way of shutting down cleanly.

I have:
2 sec press to kill and restart MC20
5 sec press to reboot
10 sec press to shutdown
And a separate hard reset button

I might play with the timings a bit still.  
I can probably add some LEDs to other GPIO pins to indicate status, stuff like, MC20 running, playing, Bluetooth active, wifi connected, all sorts of things including playback control buttons. :)


Here's the GPIO script I saved to /home/pi/raspi_gpio_actions_INT2.py
I also added this script to the crontab @ reboot with crontab -e so it executes every reboot.

Run crontab -e to edit crontab
Code: [Select]
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
@reboot /etc/MC20start.sh
@reboot sudo /home/pi/raspi_gpio_actions_INT2.py

/home/pi/raspi_gpio_actions_INT2.py
Code: [Select]
#!/usr/bin/env python2.7

from time import sleep
import os
import subprocess
import RPi.GPIO as GPIO

CHANNEL = 3 # GPIO channel 3 is on pin 5 of connector P1
# it will work on any GPIO channel

GPIO.setmode(GPIO.BCM)
GPIO.setup(CHANNEL, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# setup the channel as input with a 50K Ohm pull up. A push button will ground the pin,
# creating a falling edge.


def system_action(CHANNEL):
    print('Button press = negative edge detected on channel %s'%CHANNEL)
    button_press_timer = 0
    while True:
            if (GPIO.input(CHANNEL) == False) : # while button is still pressed down
                button_press_timer += 1 # keep counting until button is released
            else: # button is released, figure out for how long
                if (button_press_timer > 10) : # pressed for > 10 seconds
                    print "long press > 10 : ", button_press_timer
                    # do what you need to do before halting
                    subprocess.call(['shutdown -h now "System halted by GPIO action" &'], shell=True)
                elif (button_press_timer > 4) : # pressed for > 4<10 seconds
                    print "medium press > 4 : ", button_press_timer
                    # do what you need to do before rebooting
                    subprocess.call(['sudo reboot &'], shell=True)
                elif (button_press_timer > 2) : # press for > 2 < 4 seconds
                    print "short press > 2 < 4 : ", button_press_timer
                    # do what you need to do before restarting mediacenter20
                    subprocess.call(['./RestartMC20.sh & echo "Killing MC20" &'], shell=True)
                button_press_timer = 0
            sleep(1)

GPIO.add_event_detect(CHANNEL, GPIO.FALLING, callback=system_action, bouncetime=200)
# setup the thread, detect a falling edge on channel 3 and debounce it with 200mSec

# assume this is the main code...
try:
    while True:
        # do whatever
        # while "waiting" for falling edge on port 3
        sleep (2)

except KeyboardInterrupt:
    GPIO.cleanup()       # clean up GPIO on CTRL+C exit
GPIO.cleanup()           # clean up GPIO on normal exit


And here's the MC20 restart subprocess script (you cant call a user level subprocess within a root script without some funky scripting so this was a quick work around)

\home\pi\RestartMC20.sh
Code: [Select]
pkill -f mediacenter20
echo Restarting mediacenter20
export DISPLAY=:0
/bin/su pi -c mediacenter20
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 14, 2015, 03:14:19 am
The Prototype is coming along nicely. Better get that cheque book ready Jim! :) LOL
 
Somehow I have to fit all this into the case. By a great fluke of luck it looks like it will actually fit by reorienting a couple things!


External add on ports:
1x HDMI out
1x 3.5mm Stereo jack out
1x Power in/charge
1x HDD USB out

External Pi2 ports:
1x USB wifi
1x USB BT
1x USB HDD loopback
1 x Ethernet
1x spare USB

Add on Switches and LEDs:
1x Power on/off switch
1x Momentary On switch for combined Status toggle/Restart MC/Reboot/Shutdown using the timer script
1 x RGB LED for Pi status during boot and maybe other status reporting (using quick press on the momentary switch to toggle status)
3 x LEDs for front panel - (Blue power/Green MC running/Red HDD)
3 x LEDs for battery status

Yet to be decided:
Button controls for Play, Pause, Stop, FFD/REW, Volume (These can certainly be added but I may have to fabricate a circuit with surface mount switches for this once I know how much space I have left)
A small screen, maybe though that's getting a bit hard to fit now.
Fitting a DAC, though I'm not sure it's worth the effort or I'll have space.

I'll also start development on another prototype based on the standard case with micro switches and LEDs once I get this one working the way I want it.
Maybe Jim can sell the case with an optional lid/case with the buttons and leds or wouldn't mind me selling them as add-ons.

I'd ultimately like to miniaturise both designs as small as possible and design my own brushed metal cases similar in look to the FiiO stuff with some circuit board designs and surface mount switches and LEDs to shrink everything down.
I'd like to make the larger brick case with a user removable HDD slot and battery.  That would be cool.

Well I'm off to tinker....  ;D

The collection of components and development bits.
The add-on external ports are keystone mounts that I'll figure out a way to mount cleanly.

(https://public.dm2301.livefilestore.com/y2pNVRk1auS36E8EHI70ZC3rb6ejqGzytgyrhEHJucB--k1O3LkITewgumd4zifNdTJsgYf0anrMJ6z7toqzpQxrdrE3qMdVA21ZOBFAryC9ck/20150314_072306508_iOS.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2p_k44lF0R8O4JY2C58zs_0Uq_LI3TzvCBDmty5g4i2ZMb0qNwpUCuXd99S7LY9CAOi1Yw70qLgKWu6N7g0pp84BmuC5dqlqxsTjhz-f6py68/20150314_072249208_iOS.jpg?psid=1)


As you can see I'll be cutting it fine fitting it all in, but by re-orienting the Pi and sliding the battery under it I have the room I need for the additional external ports. (just)
(https://public.dm2301.livefilestore.com/y2pj3WZyHtHZEQ1zq6uxFWbaDVA3AUH9sJPustNWJZm0Sw8BnRYHVZWqROmyBnwcaIZLRvVTKb4koNleuoTm-u8Tu2tv8WZ6Yp_Xis9KpvQgZ0/20150314_072339797_iOS.jpg?psid=1)


Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 14, 2015, 04:19:01 am
Yeah it fits!

I'll be making cutting templates and dremelling my little heart out tomorrow. :)

(https://public.dm2301.livefilestore.com/y2pUK11ReVWxCgp58FjV5jdugH8eHZQyOSkTnuobcCE2opWNElWvx3sLh3TXvqSG78t-7o5tQjodeKSSxjg0fzUOpl5lm-e9_yNKB9umR2W_O4/20150314_091606459_iOS.jpg?psid=1)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 14, 2015, 09:06:14 am
Here's my first proper attempt at GPIO control of MC20 on the Pi2.
So far I can restart MC20 and get the LED flashing to indicate it's received the signal and is rebooting.
The LED goes out when the command was successful.
I also have the reboot switch working which was less of a challenge.


https://www.youtube.com/watch?v=bpzQME_Gwg8
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: JimH on March 14, 2015, 09:31:32 am
Where will it stop?  ;)  Cool stuff.

I added the embed link.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 14, 2015, 09:36:36 am
Thanks I cant do embedded links can you please do the 3 above too. Cheers!
 :)

BTW it's my pleasure to tinker with this stuff.  I'll make you a MC20 player you'd be proud to sell! :)

(https://public.dm2301.livefilestore.com/y2pEnFLEiwYNqj2N5OsnNJr9Ky1cMIbk28eYeMeRzo1AbfpoviJQyoFe5yr4i78Ca4EUb4CmIe6ctl1UPvF8s-d8qwXoYZ4SftgYSr4JY0k-u0/20150314_144224186_iOS.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2pdJQ3MN3_e7DldKdx5d-t1txEhe1tuId_xzqItCJUiwVW8elbcDVaX7-mpGfPOVD-LqR6NgsvqU4p3MOfHX55VKwW4H-m8FtbhOjhtM4VVT8/20150314_144153331_iOS.jpg?psid=1)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: JimH on March 14, 2015, 09:43:53 am
You should be able to add [ html ] and [ /html ] (with no spaces) before and after the link you get from Youtube.

I look forward to your future episodes.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 14, 2015, 09:56:28 am
The html tags get stripped and deleted for me. I'm pretty sure I've mentioned this before, I don't think general users can post html by default because its a security risk. (I do have some html knowledge so I don't think Im being dumb, I actually copied the code from your edit and it strips the html tags when its posted.

Maybe you can get my permissions changed. :)

Here's the complete youtube playlist for the Pi2 Brick MC20.  I'll update this as I make further developments.
<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=PLidW7ho7KcuCxXGSU0l_5MV6w4shFxIYn" frameborder="0" allowfullscreen></iframe>
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: lepa on March 14, 2015, 11:32:11 am
Cool!  8)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 15, 2015, 06:31:07 am
I decided to work a little more on the layout and mounting method today with cables in-place before I start cutting and I've now got it sorted.
Everything fits where I need it to fit with a little space to spare.

The battery will mount in the top of the case with the main power button and battery LEDs.

The Pi2 will mount from under the bottom panel with 4 small stand offs.
The HDD will also mount from under the bottom panel with 4 long screws through hollow stand offs.
The 4 keystones will be glued into cutouts in the top cover.
The Pi2 will also have a cutout in the top cover for it's USB and Ethernet port.

I'll have main power button and reset switch on the back panel next to the keystone ports one above the other.
I'll have the main power LED, HDD and MC status lights on the front panel.

I'll probably have to make a super short HDMI cable but I can buy the short OTG cables for everything else internally.

(https://ukqqpw.dm2301.livefilestore.com/y2ppQCFgFGhiT8-9yP9j7dCoS9m0RtPWKSp-lq1WAFc9SVqyN8ZSDomMbRGv38k8sxZkPt88xqSYCFJwqnOs3RUo7p-Gbsy-OLIt3HsSFAEQAdbZZe2G_VsooHWBWMFD-aIGdj6YtgflbEg5PA19FGhjw/20150315_110351820_iOS.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2p_axjlMVqJbKjqcrl6svmvPI-oukyg-A4K4apVoEAC_0PK6T5F75gYmNxCJLJvkYEObgjOFyy5uz1yAsTInJ-VhplwUgghHWOe_drigLPl1FC4FZK2C5xyZW4C64py0i7c6z9QXxQVEdzbjRoGWVoGg/20150315_105926198_iOS.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2pYWHowkGqu2J9ND1MgF0uulFnYQint1wVc-NC8TMdcqx_zeIQXVThgP8sEbLvMQmv7TETIuNeTuBg1nLmOUOYMXs1u9mXT3grZttGqDlYbUT2GLLWiLWSCJgVY5lp9YktJKWZdzMtMgkX8p8Nj9QZPQ/20150315_105911674_iOS.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2pnBOriNCyGpMHP1nXGQvlsxkBGDMf3Ma8AJKyWnemFNA_bt2Sy_0vj1_XSU_goUZLMil7lw-mW5oqYaahto3TPIYJGamqf3VHET_OqRNqK2tB7-ToZX_nnpcbYw1XSzHAUpM6p69St3zv5o1LRS55NQ/20150315_110026176_iOS.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2pYPFqx370cX-apfKwqY7DELpizGa2a5Y_ANcQy73yts9_nH3SgrVzraR_r_1ACPzzYqdNqPehwT5NJEwRrOizGYUDly-fYsXjF5MZIwNR8jZvjyR6FQ9HNOD5Gwj29xqeQfXVqZqEY8SnwN9S4jC4UA/20150315_110132051_iOS.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2ppFK6Z44Ey421AnLfvxVDXl0qTjY27tq_MN8KSq94pJ_J9RgyQm0mvTpIl7ScDhgfbpfQIh7ZJxI6iSRsytTHhzoN8Zj-8IvVmvcKIHcVHHWMB_sqKsoI63HooPpNYlEdUNrQf9JVjQraKuOBk67enQ/20150315_110216125_iOS.jpg?psid=1)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 16, 2015, 05:36:10 am
The final design and layout is almost done! But, I'd like some input on port locations before I put the case under the dremel!

What do you guys think would be more aesthetic and practical? (excuse the messy bluetac holding things in place!)
Ports all on long side at the back (case length ways), or ports on the short side at the back, with pi ports on left (case depth ways?)

See the Vid and Pics below.

https://www.youtube.com/watch?v=ht1xwWpxaEY

(https://ukqqpw.dm2301.livefilestore.com/y2p1f1lYDeIlcbk8NR3eGe1EC6Ua7NpR96_iN6HfiBGfmg10HS9afVs7QDL-PpjVX4ikZTcyvhI_B1O4tG2PkfEgPkaN83oOPBLtLH_W43eOZA4OcJJ8vEYD68cYnmYxMPbU4Vwd-_MmNk2gPGZnrHK7w/pi2-case1.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2pQk1408ud5i1LuKzWPi5tspLu1X4Y7iE8B1r0MiV3hCMCF2QkH34kOkBAzvpe18Ji6nabyO8ymVuf9xQ2xLZgHmUIS4Zvr-8tUlg151ssircC90G1W1g8fV0EkwaQU495uCmR-ZUyWbbCgjCuU1WWeA/pi2-case2.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2p6zA4zfEEJ7PAe0w911STk0rBYbwBM-nxBwfT7FVgx12pL0c5kEsYwmww49iKZUFnSSoqNreYlTmrvBtte1GnN5dr5DrHemKexAdsF83DIGFBRw4df5A-OuvPiXCvHXcB6MB4zsQl1YDH6NiPMqRdzw/pi2-case3.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2pD97H4roXzwQ0VNGgLNDuirTAqa7UeHnNSTuvmm8liGPmG1r_F8yeISJbDeoznlvpRwD85NTCmoezaTsaOgfyCsELnS-FyXxd-b8tpS6_a3Mg4WuUqXYRhiRRWWQAsXKaClHZtKh_igyvyPRHtJupwA/pi2-case4.jpg?psid=1)



Ports all on long side.

(https://ukqqpw.dm2301.livefilestore.com/y2pwLX8Ako1gxPDCKbVI6bYCUaaPqjDLSO6zxc0iLyQaUjFw6mjyTZNzeglP_jEMpM2KmVz5JXbPmGDc_9pliXY8YagzW6WDjuifokf96r5ckdtJGKzPIBa4RPHvvhsbFCT1NxxT9edTaPWCwgwhdoKuQ/20150316_110241018_iOS.jpg?psid=1)

Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: bob on March 16, 2015, 01:26:01 pm
I like the ports all along the long side.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: mwillems on March 16, 2015, 01:59:47 pm
I like the ports all along the long side.

Me too
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 17, 2015, 05:17:40 am
Thanks guys that was my preference too.

I have the case assembled and complete now, just need to add the LEDs and switches, drill the mounting holes for the Pi and HDD and the prototype is finished.
It was a very tight fit but it worked out exactly as planned!

There's small air gaps between the HDD, the battery, and the Pi, but I think I'll have to cut some ventilation holes too.

I thought I may have a real challenge with assembly but things just slotted together nicely in the end.

I'll finish the rest tonight and take some more pics before I start road testing it over the next couple weeks to see how reliable it is and how hot it gets.
I've been using it in the car fully enclosed in the case for a week and notice it can get quite warm.

I'll start having a look around at options to make a more refined case now, whether that means 3D printed cases, laser cut acrylic, or metal fabrication or a combination I'm not sure yet.
What do you guys think?

https://www.youtube.com/watch?v=CAJIgg50fuc

It's not quite a slice yet, but I haven't asked for US$300,000 to design and build it and it wont cost US$280 either!
I think the guys that backed slice are bonkers and have wasted their money.

https://www.kickstarter.com/projects/fiveninjas/slice-a-media-player-and-more

Not much to see here!

(https://public.dm2301.livefilestore.com/y2puviCnfQczjMMIdOvs3bJT1faNygfENOkho-wSg-jGLkw9bRa0_wnOeBab4L4bWoVQyV40a68P5MExZFyfYp8c9IvDAJB7dPU8NAPO1vlKdI/pi2-case1-cutouts.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2pw1_lo3DX_PigTQmpad9AsJHDHgcNPQO1KbgVhMm9mdKF6G5vOyeQbCPUzswmG9xn_rtH-mylJN6biVp-z__wHZq0AtiHsTEAyWIa-hk9_x8/pi2-case2-cutouts.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2pP2D2y5j9PV68JuWg449sJek89foiJChjzuLY2-3wtAF_q34YNOoZ6lOr9L4ZTAaLy4OnXGjMqJoO1hNbs2O65fWBlpka3UetZRPPPmVldpE/pi2-case3-cutouts.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2pJctdUp72LjJuRdPCpGIfQYX6LJtDNPsP0x_XhkD3oKm4twCMEAsITZ7VvQzPotI39JGop-u30AHqRWkYAPFuvxS_ES5PhpPX0FMiMBPww2I/pi2-case4-cutouts.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2p0puJcm-MukNl0QGbAi-gn2FEGDGGwOq5rk6QkKnldke3n_oP21gcObDxIopINUyMjnqteB8-xXXBIGd1IUIthd14x46CrL0Xo0kUNkVo0oQ/20150317_104059564_iOS.jpg?psid=1)




Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: mwillems on March 17, 2015, 09:42:43 am
There's small air gaps between the HDD, the battery, and the Pi, but I think I'll have to cut some ventilation holes too.

I thought I may have a real challenge with assembly but things just slotted together nicely in the end.

I'll finish the rest tonight and take some more pics before I start road testing it over the next couple weeks to see how reliable it is and how hot it gets.
I've been using it in the car fully enclosed in the case for a week and notice it can get quite warm.

I'll start having a look around at options to make a more refined case now, whether that means 3D printed cases, laser cut acrylic, or metal fabrication or a combination I'm not sure yet.
What do you guys think?

A metal case will be more expensive (and harder to work with), but will solve your heat dissipation problem much better than ventilation holes.  As tightly packed as you've got everything in there, ventilation slots may not be enough to dissipate the heat, so your next step in passive cooling is an aluminum case.  That's basically what Flirc did with their pi case (turned the whole case into a heatsink).
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 17, 2015, 07:31:38 pm
A metal case will be more expensive (and harder to work with), but will solve your heat dissipation problem much better than ventilation holes.  As tightly packed as you've got everything in there, ventilation slots may not be enough to dissipate the heat, so your next step in passive cooling is an aluminum case.  That's basically what Flirc did with their pi case (turned the whole case into a heatsink).

I found the right case for the job. It's a little pricey @ about $25, but that's pretty good for an extruded aluminium case. :)
It has a sliding removable belly plate and they do screen printing, drilling and milling to spec too.

I'll get one to check if everything fits and then go from there to work out if it's feasible to get them made pre-cut for the cut-outs I need.
My CAD skills are a bit rusty but I'll give it a shot. ( I did some CAD work and metal fabrication and machine work in the late 80's :o )

http://www.dlpc.com.au/ham/pdf/1455N1601.pdf

PS. might be better off going with the slightly larger version so I can mount all the ports on the short side and it'll be easier to machine the end plates.

http://au.rs-online.com/web/p/general-purpose-enclosures/7733003/

(https://public.dm2301.livefilestore.com/y2pKul2I9ADmzpJqyov9FCVRvlMvffeEMr6Nch9FWnImeOY4yPH-D7hwrcrYeDH--vPSP0tyAQDQw3Nr8tewVdfbQ1TXuriikhBMNQZZ0gBao4/R7733003-01.jpg?psid=1)


Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 18, 2015, 03:22:27 am
Pi2 Take II - Miniaturising the Pi2 Media case.
Yes we can make it smaller!

https://m.youtube.com/watch?v=E1ut6P6OVIQ
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 18, 2015, 04:28:50 am
Here's a teaser shot of it working with a standard SSD with a USB 3 adapter. :)
That means you can use any standard Sata drive and it can have the slot removable drive that I wanted.

It all fits!

Because of all the electrical connections at the back I've decided I'll cut most of the back panel off the metal cover, and fit a plastic back piece that will be easy and cheap to get made up with all the cutouts.
Then I just have to drill a couple holes mount a couple LEDs and switches and that's about it.

I'll put a thin layer of insulation (microtherm) between the battery and the CPU to keep them thermally isolated.
I'll turn the case into a heat sink for the HDD and battery and make a metal heatsink for the CPU that extends and attaches to the case.

Finish the brushed metal look on the lid of the case, coat it with a protective layer and/or colour so the brushed metal look still shows through.
Screw a couple rubber feet into it...

One sexy battery powered Pi2 Media Center with SSD or HDD. :) How many would you like to order?  ;D

(https://public.dm2301.livefilestore.com/y2p6-gE8kZL6-8HHEXU1MVCAI-OwmTZ07hMcKpOSycWgxbtprrw-DAC2ksdg74iGI6dV64kHGSgrGub652ysa8y_awKffbgAfhqU4xFHHg6ihg/20150318_090928260_iOS.jpg?psid=1)


Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 20, 2015, 12:07:22 pm
It's almost finished.  
Everything is properly mounted now.

I just have to drill a couple holes for switches, and another LED or 2 and rewire the battery and the hard part is done!

I've ordered a short HMDI cable and I'll mount a power jack at the back and headphone(lineout) socket at the front.
The power switch from the battery will be on the lid in the center near the front.

(https://ukqqpw.dm2301.livefilestore.com/y2pMNMHnqn0G3KQhNxLf3yjeGmtWH1HrdGuP2RjKbfsDzScXGVRWmCoFne4UAFcM1FyEna054Aops9n0zASpkFj36fkwihSMzPdqrNjX_FE_rpUM8P_9ZHoV8oq2vwWZ6PyIYMFVKkfhTv13ygVrAXdzg/20150320_165358180_iOS.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2puCx6xmLNxbJRfkkWdDraiqBmfBKPuvmEa_E0SfpbuiVwTgQGcjgGUUCKTgNfpKjOG0LHkMdZ3lKH9AMmIJ__AeSOT32FON5PV4NOMum4zKt-2lEJPDw6SFDme1tybgie1Ipd8ubpn5hUl3i-9DgJ2w/20150320_165425298_iOS.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2pmP5zsdCmQZIoMwyK3Zi5ZhL9yaPMBL8QUEH7S10jVQzkPKF2rCyIiDc9gkCIPiu3M4VTA6MGCspsljfti4K48_k9JMPMCV3dRN2jyqtG96RUqr0suCo5CjtuoQAS5-1gukLKKdiO8z5ipswNQRvSGw/20150320_165631051_iOS.jpg?psid=1)


Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 21, 2015, 09:00:44 am
Looking very steampunked in its naked aluminium now.  :)  I like it but I'll still paint it with a semi sheen black.

I found a battery with more capacity (6000mAh) that fits much better today and the charging circuit layout allowed me to mount the micro usb charging socket with direct access from the back.  That should give it an extra couple hours or so.  All the ports apart from the headphone/line-out port are at the back.

Not quite up to the look of the FiiO, but I don't think it looks too bad, and it'll look even better when painted.

I only have a few bits of wiring to do now and it'll be finished enough to use while I wait for the HDMI cable and work on the back panel.

(https://public.dm2301.livefilestore.com/y2p1WP7Qi80CQ6sF7vwiapxjEXhNEx6Hz6CHxdljKk51GKX1bQnSy1O6FPV-dIu5YyzlJi3Z53h-rAonm1ksU628BdmQAVLONEXIk-hBs-hpjk/20150321_132731800_iOS.jpg?psid=1)



(https://public.dm2301.livefilestore.com/y2pVv9SIzDzkOr7bGvY9jGGCdWcsEvUngoO9ZIZZpw3kufBZvF5HstLxX4INK_DBpYUsj4O7R5RRfp2EYQr4oFx2KEk4qn09M5UOcvMotfgtqY/20150321_132911731_iOS.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2pUdk8W9qztF9y3P7RQOtwBwtRgizLVk07wQUfSWB6yiOQiytow5VlSVWtubw1wTDC4wSoWN8fcbhwJ0NcbArjiK1Mbk0JOe_UQO5FrTpcmcE/20150321_132953799_iOS.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2pkkr4C_H42_ltCCDaI6DowHm9PKk74RlvaK0szPDjLf5Cf1rbEiL3mFaXngPPDU-J1BojHIA5h466RuXWwe_jSRtflU6OJFNhPGGtcOGTP5Q/20150321_133324222_iOS.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2p8Tzme6-2j0CIk-lqzcK5jzdzGIKxb2UCiOJ_Am8oO6dv5p3r_l9o3uT1VzRBucj6AQmroq2MILEbFnywo_lQofgzwB89yWqzUZg-UMaJBfU/20150321_133420584_iOS.jpg?psid=1)

Plenty of clearance. :)

(https://public.dm2301.livefilestore.com/y2psHCLnuJtSQGyrFqDMIO5IXBttTdEjQPAOhzAzLRqpXrXgpNHd1qVylD5JD7mUM58Ficmntrx6eQViht4Fn5rAVuxC6tcAOZH8tuBbQmDrxg/20150321_133529775_iOS.jpg?psid=1)


(https://public.dm2301.livefilestore.com/y2pCQUJ1MEVxzE6K6RZFkTVr_JRKn5Zu1ac8j_6S7MiY6OKQkmLqHmPTABn-4Nyesz9I_E__8l48dRe-1Y-nGOKoqxGLH5JO1AWOacs6VB_EFg/20150321_134217156_iOS.jpg?psid=1)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 21, 2015, 09:37:58 am
Now it's time to start building a DAC and an AMP to go with it. I may even use the same case. :)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: Hilton on March 22, 2015, 01:28:22 am
99% finished - Stress Testing for a week before I make any more decisions around extra controls and cutting or painting the case.

More Pics and Videos on the way.

If anyone has any suggestions before I make the final changes I'm all ears!

(https://public.dm2301.livefilestore.com/y2pBLtJK0MBmJuZ-Qf7zYFmtmFSHveSM8ekeqoF-0oKwOfZIxRU6Opoy_AOdax7vOMEIwxvqjBAXrWUJjW8QyVO4_JWA7_ytbfrL6-gmGz5iwk/20150322_051654495_iOS.jpg?psid=1)

Demo
https://www.youtube.com/watch?v=VLM5V6JLfY8



Video of Inside
https://www.youtube.com/watch?v=2dgkL1ZcBqs



Pics of Inside
(https://public.dm2301.livefilestore.com/y2pMmycPIc8mMa4PdYTKuIz5x9xrM8t8AfW_AYyNy2z6_rI95thJwHKWt3Ly1Bw8ysHrd-P6v8sb_OGMHRhry4hjWVmcfcYHn_Sal9zs4mSWgg/20150322_063402685_iOS.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2ptD23TA1rPgJHrvf-oAB6gSY-uXh0umiI0lkrqlJvCcu9YHlRnG2OQlhO26iTJvRLG4bnx8LGI46n3DcPwQXYItHHRt9itujGfwPo1wZUKK0/20150322_063426427_iOS.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2pp30AWyNEFFFi0glhwHkPPkJF5bFaZT1UnVNMfwdHARBkHI55gfJO92qnumsHXeWjPZcFbiThdG5flUtMRoW47rj5ptATRcFuoSNYGEUcizs/20150322_063523261_iOS.jpg?psid=1)










Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 500GB portable MC20!
Post by: jmone on March 22, 2015, 02:17:24 am
Looks good, I'll bring my around and we can marvel at it all.  One thing I found in my Ghetto setup is powering a Tablet, DAC, and Amp from the one DC power supply = ground hum....
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on March 24, 2015, 05:25:47 am
I Installed a Samsung Spinpoint m9t 2TB drive this afternoon.  Really quiet, low power consumption and fast. :)

http://www.storagereview.com/samsung_spinpoint_m9t_hard_drive_review
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on March 25, 2015, 06:27:52 am
I have the controls working on a breadboard with MCC commands via GPIO pins and I've started prototyping the control board for the front panel and can fit 2 rows of buttons. (4 or 5 each row)
I also have the option of fitting another 2 buttons on the top cover on the left edge or on the left side at the front
Unfortunately the front panel or the top cover at the front are the only locations I can fit buttons or switches.

Possible button locations:

(https://public.dm2301.livefilestore.com/y2pdL9Lmw4Ge6EoAzOegnKSa7ObiAtd62k3qBnIFs93V7iIxrXBu4zS4Y58iOi5bZ0W4NWuF1njDu1oBe5LKHiehcty8RhSOv5HTtqeKwbmzQ8/Pi-case-controls.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2pOkm1CNDYfMfgVcF1LL5Q8qACIaOrjbx-BIItKb5CfzCsXs6-B4RJibqmKk5aafpKN-A_c19YZEjM3xUq7tDHZ1P5SrtPC2JznDJQqWp2AzU/20150325_103633985_iOS.jpg?psid=1)

I was thinking of player control buttons << > x >> for the top row and maybe volume for the two far right buttons on the bottom row with a mute just to the left. 
That leaves 1 or 2 spare for reboot and restart MC which I can recess so you have to make a more deliberate attempt to press them.

Im not really sure If I should bother including player controls as I don't really need them or the volume controls, but I do still want to at least fit a reboot and MC restart.
I've found matching tiny chromed button caps to make the controls look a bit fancier.

Button Caps:
(https://public.dm2301.livefilestore.com/y2p8_zQMDaTUVgYZK2tnpxchFvg4cEJ4Agu7j0cTLkApeaWJ6tJIzlr536z9El8bMYv7mUNz-OrW_lQ7hEv6uq4C0YfTs7xB5YzCkY2mvSMMJ8/switch%20cap.JPG?psid=1)


I've also found a power-on / controlled shutdown module with switch that I can fit which includes an IR sensor. I'll fit it to the left of the control board.
I've also got a small RTC board so the Pi keeps the time.

So what do you think? Should I mess up the front panel with controls or just stick to the bare minimum?
Are there controls that you think would be more useful to have for running in headless mode?

Other options I've considered are:
WPS Wifi button to join a network
BT pairing button
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: BryanC on March 25, 2015, 10:20:06 am
(http://smhttp.23575.nexcesscdn.net/80ABE1/sbmedia/blog/wp-content/uploads/2013/01/roku-xs-chart-pics6.png)

I've always liked no buttons (that instead exist on a remote or only via a headless interface) because it means I can hide the thing away when necessary. If you want me to nitpick, I'd say the same thing about the toggle switch. It's nicer to have the power control via the power plug because then I can extend power-on/power-off away from the player if it is hidden. MC updates could easily be handled on the next startup.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on March 28, 2015, 12:10:46 am
As much fun as it's been getting mc controls to work via buttons I'm starting to lean the same way. Less is more.
I've been playing music from the Pi2 for probably 30hours this week and I haven't missed controls apart from a shutdown and the need to restart MC via SSH a couple times.
When my power module arrives i think I'll just put a small power off and restart MC button on the top and a tiny Blue led for power and a green led to show that MC is running, along with a small opening for an IR sensor. That should tidy up the front.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on March 29, 2015, 04:30:53 am
Not much to report.  The Pi2 and case has been working really well the last week.  I'm getting between 5-7hrs out of the battery and it doesn't get too hot even after 4hrs of continuous play.

I did rewire power yesterday so now it has uninterrupted power capability.  I can have the power plugged in, switch to battery and vice versa, without powering down.  This is handy in the mobile context where I use it at home, in the car and in the office.  When ever I've got power available I can switch over to mains and charge the battery and then go back to battery.  It's not automated yet but it can be with a little more work. For the moment I still have to remember to switch the battery on or off, but it's great to have the portability with continuous playback.

I've got really short 10cm/4" USB 3 HDD cables and SATA to USB dongles on the way for the HDD which will tidy the back ports a little more. They should arrive mid week.

This week I'll finalise the design for the LED's, RTC, switches and power circuit.  I've decided to leave the playback controls out for now as I've been using JRemote to control it just fine and I've never missed having controls on the case.
I'll still include a discrete minimalist shutdown button and restart MC20 button though.  The power LEDs will indicate whether it's on mains or battery and there'll be battery level indicators too.

Oh and I milled the lip off the back of the case now so the HDD can slide in and out without having to take the unit apart.

(https://public.dm2301.livefilestore.com/y2pltsR7foKSGySTM78hSJSX1jTO5dZlEodP25mLmWOWbXCHnlQnxkJuyIePK3ozK-0SppR-ysY5GkFipcu1q3gm9cy4gVYZWIs1xZszGGncco/20150329_093952364_iOS.jpg?psid=1)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 05, 2015, 09:56:11 am
I've sorted out what's taken the most research!  The darn HDMI connection!!!
The cables I ordered were still too stiff and thick to fit.

After hours and hours and trawling websites I've found these HDMI FFC cables. They're darn expensive so I'll have to source the individual parts and make my own PCBs if i'm going to even think about mass production.

(https://public.dm2301.livefilestore.com/y2pBe5weyok6cJ_VFDo_VKOcpfZBvP5waK6n5upItz2PNxwfU18IUBfL8-ezT0DrpXWp8V5V2cVucbpib2mNk3GpbnGi-TIBKPHs2O3oDzYYzU/FFC-HDMI.jpg?psid=1)

I've ordered some LiPo charge and converter boards from adafruit to finalise the power circuit.
So It will now have hot swap UPS power between mains and battery and automatically charge when plugged in or switch to battery without rebooting.
It'll also automatically shutdown cleanly when battery gets low.

(https://public.dm2301.livefilestore.com/y2p3rVPJNNiKOXUX2Sq0ceyWJYlB9WUPjd7Dw99_IvhFxvNBR2pCjtbYGXa3qxfvuIyGMm2gzUe5GXXQGdkMP9ozYphIlIXXx15t924HtUQOCA/Charger.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2pbWsyZXXtInEWEAm3oMoA7N8hy3d_SIt7Dwm-mdM4BiRiIgIuQsVMtE9N3Yvbr37l5D8jVq2a21DV0sAD9s0FkTswh-UrlBIOOcxxQ2-aExc/Upconverter.jpg?psid=1)



I've ordered some nice really small blue LED tactile switches to replace the toggle and led with a single tiny led lit switch.
With the new compact HDMI connection I'll have room to move the 3.5 stereo jack to the rear and have a really clean front panel with just the led switch.

(https://public.dm2301.livefilestore.com/y2p6eM0E2T-AUjXyqmUwXH2A2cGrH-8UPVp9DFVZvOVS9KP6R5VoUOxLLFJTvMScMKwPnUE7XjUZHoc0_p6yTmsx1rICj01RlVwbBsoTFQ24fw/LED-switch2.jpg?psid=1)


I started designing a case in CAD (how tedious!) and MC20 on the Pi2 has been running great!


Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 10, 2015, 09:48:28 am
Still waiting on a few more small pieces of the puzzle but the new powersupply works really well.
The internals are very nearly finished now.

I don't get any power brownouts at all any more with the new power circuit and I can plug and unplug the power without rebooting and it automatically charges when plugged in.
I got a new 4A 5V powerpack shipped with the internal power circuit with an inline switch too. :)

PS. I'm using this several hours every day in the car and in the office and it hasn't missed a beat going between the office and the car without having to reboot.
I love it!


(https://public.dm2301.livefilestore.com/y2pP-ChXqrIVfChPEFJOZMjJI6i-Y9SiidhWP4p9cq8p7z9ceuknlLWRKyJBY3Oi9wTOuln95B12c8prdTPSJhq7_lmmS8Ju0_Hx6JaHSL2mC8/20150410_144151499_iOS.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2p0dehG4apFEzWF6Ar2ScbBJ6Gp-hfBMnFLRefDJWiVZVyNQfbglNViJQRJ9VE9Z14HMIeVxsoXKO064ltCqJPOe7KThAxdo-2KbUuI7H2A_8/20150410_143636127_iOS.jpg?psid=1)


Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 12, 2015, 10:11:45 am
Tonight I finished working on my GPIO control scripts and have a single button to restartMC, reboot and shutdown. The LED shows when its finished booting and turns off to show when it safe to turn off the main power switch. I have it all assembled and working and will make a new video demo tomorrow.

Things left to do:
A couple better smaller switches.
A better smaller LED.
Fit the realtime clock somewhere.
Fit a battery level indicator somewhere.
Still waiting on my super thin HDMI cable.
Still waiting on delivery of some super short micro USB3 HDD cables.
Make a back panel.
Smaller rubber feet.
A paint job.

Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 12, 2015, 10:14:55 pm
Getting a bit toasty @ 60c with the new layout and no heatsink on the CPU.  No stability issues but that's a bit warm, and the case is about 40-45c to touch.
Will have to make a heatsink to transfer the CPU heat to the case.  The HDD and battery operating temps are up to 60c and the HDD is also sitting at about 43c.  :o

(https://public.dm2301.livefilestore.com/y2pkUyCimGF9r5N6rosZqU0eczGJ3nw0TBZ8oSzgpF3Ku6E9_mO27lfQVyTx_R0V6-pfhi3itkW7VqkC5SpRZjnpXd-GeFdjJgmjHH_1faVgXc/Pi-Temp-no-heatsink.JPG?psid=1)

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   100   100   051    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0026   252   252   000    Old_age   Always       -       0
  3 Spin_Up_Time            0x0023   087   082   025    Pre-fail  Always       -       4000
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       200
  5 Reallocated_Sector_Ct   0x0033   252   252   010    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   252   252   051    Old_age   Always       -       0
  8 Seek_Time_Performance   0x0024   252   252   015    Old_age   Offline      -       0
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       165
 10 Spin_Retry_Count        0x0032   252   252   051    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       217
191 G-Sense_Error_Rate      0x0022   100   100   000    Old_age   Always       -       5
192 Power-Off_Retract_Count 0x0022   252   252   000    Old_age   Always       -       0
194 Temperature_Celsius     0x0002   062   057   000    Old_age   Always       -       38 (Min/Max 19/43)
195 Hardware_ECC_Recovered  0x003a   100   100   000    Old_age   Always       -       0
196 Reallocated_Event_Count 0x0032   252   252   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   252   252   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   252   252   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0036   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x002a   100   100   000    Old_age   Always       -       0
223 Load_Retry_Count        0x0032   100   100   000    Old_age   Always       -       2
225 Load_Cycle_Count        0x0032   100   100   000    Old_age   Always       -       2043
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 13, 2015, 05:35:25 am
Here's the new look with combined switch and Blue LED ring.

(https://public.dm2301.livefilestore.com/y2pB8DekAM6y0OD-bRRJ8GhqlTv51eGQL6NaHxqGitO9Vh76bLfAicPIeLUdr9E5Vk8PDHYeMsIYMx5lRHb0OERIpb7gR6rehnyFxKecQAD6PU/20150413_103058668_iOS.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2phpmXqesJcW9vatcLQvNxq6MDmri8qsAkanxltP-IbUK53_kqnBLCmAL25s4283bgYxIGAc3kiJ3WptI4xXjnvqjpFceJpkrLOZCV6pyaMFY/20150413_102826976_iOS.jpg?psid=1)


Here's the rather crowded looking internal shot with most of the wiring done.  

(https://public.dm2301.livefilestore.com/y2pwpOtyod3x-2g3n7fxCOQQ0S16COanb-U2uqjaNyf93oPru66cDkBnCW7mhk3yrnDF7x7UZZgrbnj8GndbVfRfPBeKccHeJ6DiN4TTy1To4U/20150413_091314610_iOS.jpg?psid=1)

(https://public.dm2301.livefilestore.com/y2p5gfCW6S02KZUWBv68-f4j326-57EjToQYhDNIARL0K6FkJTtOtgfE8bCqxBrSG1Y7KbyVSCZoINBNgMCwBtirD4kNkM6bHwvUJ9TUq78VfQ/20150413_091331431_iOS.jpg?psid=1)

Only a few things left to do.
I have to fit and wire the RTC and battery indicator and there's still some space left believe it or not!  I may even be able to fit an I2C DAC with analog out.
Im still waiting on my HDMI cable.  :(

I like the switch with the blue circle led so much Im going to replace the power switch and green LED with another combined green LED main power switch.

Please excuse the bluetac holding things in place. It is a prototype after all. :)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: 6233638 on April 13, 2015, 05:38:27 am
I don't check the Linux forum very often, so I only just saw this - very impressive build, and it looks like it would be a fun project to do.
I look forward to seeing the finished product.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 13, 2015, 07:14:25 am
Yes it certainly is a lot of fun!

Here's the demo video of the new multifunction LED switch and the UPS.

https://www.youtube.com/watch?v=D5R_SZvNZ-E
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 14, 2015, 08:14:02 am
I went with red LED main power switch, I didn't like the colour of the green.
It's slightly recessed as it's an instant momentary on/off power button that I don't want to accidently turn it off.

In the final prototype I'll recess the blue LED switch the same as the red one, though that's not as important as you have to hold the centre button for at least 2 secs to trigger anything.

The photos don't do it justice, they're a really nice crisp blue and red.

Power on and still booting up
(https://public.dm2301.livefilestore.com/y2p-HF_VHjqzCFsqSEDTDeZZQTgPWlUItPL2rR_Nv53hjmlx1G5-uWkjchT4XSb7k78ViJM18CqUf2JIwOaAIrt1atLQ1zLru_2GL8HtFXD7JI/Pi-case-LED-switches-booting.jpg?psid=1)

Booted up
(https://public.dm2301.livefilestore.com/y2ppgqEJghs-xCpFhBmvoEnh_nIJSPrqHQVA08NfWXaqHUR-Vx4rBq0ijVkGLZUQ3uoJmH0k4tek4NZVJ6WkZ8b1Fwx7J4iBRRKYgMj6i4d9go/Pi-case-LED-switches-booted.jpg?psid=1)


Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 15, 2015, 09:03:15 am
Here's a quick photoshop colour change.

(https://public.dm2301.livefilestore.com/y2pHUsJ_qTsMs6Ydd_6tOPD3dKxYWyptpgdJ90EReGlmCIOJSt4Cyll6A9eNdBcqT1Yg6iBhyVR1sSeNsGS_vi2ZJridSek2wsejcTho_3Ans4/Pi-case-LED-switches-booted2.jpg?psid=1)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 16, 2015, 10:18:44 am
 ;D pi M8888T

(https://ukqqpw.dm2301.livefilestore.com/y2pm_B9xOqCzL2S51suTqpFrL8B_bM6IHICHmQXiOfzMgzysvAa6xVBuOqaFbGT_8M5ncF7W5WgeY07x5o9jDrIR1uBam2MUr-vBZlBBL9zzNQsucRW-MZ1aMkO8tHopX4yuZ--X8yQ0QJw0iubsbVJnw/pim8.jpg)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: JimH on April 16, 2015, 10:31:59 am
Ta da!
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 17, 2015, 12:32:13 am
Yes it's nearly finished. Only took 4 weeks from concept to this point and there's not much design work to be done now. (and most of that time was waiting for parts)

Just starting to work out real parts costs to source them more cost effectively and the best way to assemble and produce the end product in batches of 10 or 20 as either kits or complete assembled units.

It may not be financially viable as a product but it's been fun. :)

I've been posting bits of the worklog on a couple of other forums, AVS/Head-Fi/Raspberry Pi/ADAfruit and Overclockers here in OZ and there is some interest in something like this, both as just a case in a kit form and as an assembled unit.  I have most interest from the OZ overclock forums with almost 2000 reads and the most comments and thumbs up, Head-fi has been good too.

The guys at ADAfruit have been very helpful and supportive too.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 19, 2015, 09:04:08 pm
The short micro USB3 to USB and SATA to USB cables arrived.

Looks a bit tidier now.

Micro USB3 to USB
(https://ukqqpw.dm2301.livefilestore.com/y2pKkjAOXxiwPpbIRgyDlen094MX3dcQXzgtGqdWzlCZ1FF-gjCODYb16GIKTyC_AqJ8g9-Xa9_Zaw82JaOiBshgalVNbuHtkrBSuCK0GYtR32J1pRQ6abTb61yp26hNppfybUpwqw5TW14kh-Nxjg1Xg/20150420_015001152_iOS.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2p3so1o0veQ17EwJVSQMtky_etC-E0XtOYSOgZUGVgnirunE2iGAi6p1lrRWbvUb_IZtMGdlxbV-Hmm5TQx_9xySUDCAe6qeONYLntN5xs6406HqwTJEvkzVbf-Bjd3ms4mdklBmTx8jsCIfAKsZ8s0w/20150420_015702786_iOS.jpg?psid=1)

(https://ukqqpw.dm2301.livefilestore.com/y2pDzGqW-qj24JaXvDHSVaILm4ZPAsMPhMTs9N0i5nCjaHG_zYMLApd3lVh0diO_9xh71m41lnZQ03gLLFYnrlREj2xKtvtgwBGVOtbvqPbZh6lRx8uDL-84nDV5MLAEQ4GvKEnVRX2d2q_5dz9IKE0-A/20150420_015017462_iOS.jpg?psid=1)


SATA to USB
(https://ukqqpw.dm2301.livefilestore.com/y2p3qOEdp16ioKXbZjmzDFHE7-NZZpyOehfy8IIz9bvf5kSnftn63EYWqYEeg3ZVZ0OJKsQykL-g3FDcKoOGInyX2Fv1h3O1Fd_zKTNJiDXd5aBN8DZNa9GvREVlwjrWgeapfLS-Z8V9bxwTQ4zvs_PlQ/20150420_015534188_iOS.jpg)

(https://ukqqpw.dm2301.livefilestore.com/y2ptybd3ReG0u83tcz01qMKw2F7ZgxsI3N4qC5fuXyGfyYjKNDOLVKxs-bJb7ye0cmhH-Uv--rCg-5kOI6Jv_g1mLf6NegeNP2X3zYLDHjpEW7plecvB7OeGhRqgHFsmM_5_Jjnda0q-G-7TemwLQ4sAA/20150420_015542152_iOS.jpg)

(https://ukqqpw.dm2301.livefilestore.com/y2pTMAPIld3yXITptRNYMAEFu8iW6sCjFraSELY-js1ewUMEX0Tlhz1LmYfB509fssZBxVJC_0-QSoYRxvMXoIaO8EAMNDlpglxqrpl4KeAIH-SUPmZRW5AOvOFipSWymOXyeU2xbFf30GNv9JQQx-qjQ/20150420_015551010_iOS.jpg)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 21, 2015, 09:40:55 am
Just trying to track down a voltage drop problem on the new charger circuit.  Made this video for the ADAfruit support.

https://www.youtube.com/watch?v=bjvhfrp9SCM


Battery Volts

(https://ukqqpw.dm2301.livefilestore.com/y2pBLHQnJQBs8dKsBHFDyGK0lhGs7zMvdP6WRptUF3mPXM4cusKTu_aqX4s9LyGSCuvTxLBkxJsDyAxbsD6KeuUJ1BlJzvs3KirQns8v5DZeIDFfOo8WSa13k56UlQUZQGS4LWmPNBDU2SPOHsZz_tN3g/20150421_134815995_iOS.jpg)


Load Volts (should be the same or very slightly less allowing for losses in the circuit.)

(https://ukqqpw.dm2301.livefilestore.com/y2pQE7NItafeqSXu3tgQHBu-2-fdH8W2pq0ANBy93FCkeVyw8BioYMRhHucHEKREtCRj-AxQpZPZ-0KfKNuYZOq7xp6CqqbwIOTc6IDhAWgj9rMQ22Uw1Eg0P_3y8g-b1cnM-rIf90BTgv9XBN5ZXNrzg/20150421_135002204_iOS.jpg)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 24, 2015, 06:03:19 am
Still trying to sort out power issues with the new power circuit.  Have put the original standard USB charger back in and I don't have voltage drop. If adafruit cant advise on what can be done to fix or adjust the solar charger I'll be sorted. 

The solar charger has proper load sharing to charge the battery and run the Pi at the same time where as the USB charger doesn't, so the battery wont charge with the standard USB charger with power plugged in while the Pi is running.  I may have to find another power circuit to use, though it useable as is, it's not ideal.

I measured and it's only drawing 1A under normal load, peaking to 1.3A.
I have a video below of the standard USB charger in circuit measuring current during boot and peak load is 1.3A.
Very little voltage drop with the USB charger and 4V on the battery, with only about .15v voltage drop where as the solar charger drops to 2.9V and a bit lower at the peak 1.3A load.

Playing and decoding 3x 96k FLAC files simultaneously also draws about 1.2-1.3A at 50-60% utilisation. (load split pretty evenly over 4 cores)
This is with Wifi, BT dongle, USB HDD direct off Pi USB and a self powered DAC.  No brownouts occurring with USB charger but I do get brownouts with the solar charger at peak load.

I'll be making the next version of the case this weekend and am going to try to make cutouts for the rear ports on the metal case with my makeshift Dremel CNC machine.

https://www.youtube.com/watch?v=Gn5kcwJoNZY
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on April 25, 2015, 05:10:43 am
Still working through the power issue with adafruit support.  They're sending me free powerboost 1000 combined with a charger to see if it behaves the same in my circuit.

I did however this evening get the battery monitoring working.

I got the sparkfun Lipo fuel gauge working with the Adafruit_I2C scripts on the Pi with the Adafruit USB charger. Should work with the Solar charger too.
It was pretty simple. Hook up the fuel gauge SDA (data) and SCL (clock) to Pi pins 3 (SDA) and 5 (SCL).
Charger Battery terminals connected to the JST on the fuel gauge.

Here it is measuring a very slow charge while the Pi is running with an almost flat battery.
First without power plugged in you can see it discharge and then with power plugged in, very slowly charging.

I installed the Adafruit I2C scripts and libraries and the fuel.py script from here> https://bitbucket.org/widefido/fuel/src

Code: [Select]
pi@raspberrypi ~/Adafruit-Raspberry-Pi-Python-Code/Adafruit_I2C $ sudo python fuel.py
estimated time left: 0h 0m 0s (1.27%)
estimated time left: 0h 0m 0s (1.21%)
estimated time left: 0h 0m 0s (1.17%)
estimated time left: 0h 0m 0s (1.12%)
estimated time left: 0h 0m 0s (1.12%)
estimated time left: 0h 0m 0s (1.12%)
estimated time left: 0h 0m 0s (1.12%)
estimated time left: 0h 0m 0s (1.10%)
estimated time left: 0h 0m 0s (1.10%)
estimated time left: 0h 0m 0s (1.10%)
estimated time left: 0h 0m 0s (1.08%)
estimated time left: 0h 0m 0s (1.05%)
estimated time left: 0h 0m 0s (1.07%) **charging**
estimated time left: 0h 0m 0s (1.07%)
estimated time left: 0h 0m 0s (1.08%) **charging**
estimated time left: 0h 0m 0s (1.08%)
estimated time left: 0h 0m 0s (1.10%) **charging**
estimated time left: 0h 0m 0s (1.10%)
estimated time left: 0h 0m 0s (1.12%) **charging**
estimated time left: 0h 0m 0s (1.12%)
estimated time left: 0h 0m 0s (1.12%)
estimated time left: 0h 0m 0s (1.13%) **charging**
estimated time left: 0h 0m 0s (1.13%)
estimated time left: 0h 0m 0s (1.13%)
estimated time left: 0h 0m 0s (1.15%) **charging**
estimated time left: 0h 0m 0s (1.15%)
estimated time left: 0h 0m 0s (1.15%)
estimated time left: 0h 0m 0s (1.15%)
estimated time left: 0h 0m 0s (1.17%) **charging**
estimated time left: 0h 0m 0s (1.17%)
estimated time left: 0h 0m 0s (1.17%)
estimated time left: 0h 0m 0s (1.18%) **charging**
estimated time left: 0h 0m 0s (1.18%)
estimated time left: 0h 0m 0s (1.18%)
estimated time left: 0h 0m 0s (1.18%)
estimated time left: 0h 0m 0s (1.18%)
estimated time left: 0h 0m 0s (1.20%) **charging**
estimated time left: 0h 0m 0s (1.20%)
estimated time left: 0h 0m 0s (1.20%)
estimated time left: 0h 0m 0s (1.20%)
estimated time left: 0h 0m 0s (1.20%)
estimated time left: 0h 0m 0s (1.20%)
estimated time left: 0h 0m 0s (1.21%) **charging**
estimated time left: 0h 0m 0s (1.21%)
estimated time left: 0h 0m 0s (1.21%)
estimated time left: 0h 0m 0s (1.21%)
estimated time left: 0h 0m 0s (1.21%)
estimated time left: 0h 0m 0s (1.21%)
estimated time left: 0h 0m 0s (1.21%)
estimated time left: 0h 0m 0s (1.21%)
estimated time left: 0h 0m 0s (1.21%)
estimated time left: 0h 0m 0s (1.21%)
estimated time left: 0h 0m 0s (1.21%)
estimated time left: 0h 0m 0s (1.21%)

(https://ukqqpw.dm2301.livefilestore.com/y2pyVpS68YUlstFCPDlS0eOCe-9XuS8q2LAHq1w61r08i7_TDW8zUHx58zLIC8HvEHbANRIcsPwMn5jAQElvrhp8mv8MHWZXivNPIUb3Noz6-Pv0fg57x3zsCtPJFybenO5JmFlO8Gng-5XsEVISjuUf0kvALpbubzopMPyYj5GqmU/20150425_094924924_iOS.jpg)

Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 01, 2015, 01:59:29 am
I haven't worked anymore on the solar charger issues yet, but the standard USB charger board is working well anyway at the moment. The Pi2 will either maintain current charge or slowly charge with the USB based charger. (incase you're wondering why on earth I would use a solar charger, it's because the solar charger has a proper load sharing circuit which directs more charging current to the battery when the power's plugged in and the Pi is running.)

I did get my low battery scripts working today though, which was a major break through for me! :)  Just a bit of tidying up to do.

I can't take credit for the base code, I've just adapted it for my needs.
This script will normally be set with 10% battery as the warning level where it will write a warning file and @ 5% it will write a shutdown file which the other script will detect and then shutdown - still have to add the flashing LED for warning but that should be straight forward from here.

Here's the output of the battery monitor script with the low battery set to 70%
 
Code: [Select]
pi@raspberrypi ~/Adafruit-Raspberry-Pi-Python-Code/Adafruit_I2C $ sudo ./fuel.py
Battery Low: 50.01%
Setting Low Battery Status
estimated time left: 0h 25m 36s (49.62%)
timestamp: 2015-05-01 16:12:39.991583
threshold: 4
alert: 32
volts: 3.6239
Battery Remaining: 49.62%
Battery Low: 49.62%
Setting Low Battery Status
estimated time left: 0h 51m 13s (49.62%)
timestamp: 2015-05-01 16:12:55.004299
threshold: 4
alert: 32
volts: 3.6422
Battery Remaining: 49.62%
Battery Low: 49.62%
Setting Low Battery Status

Here's the output of the lowbattery detection script
Code: [Select]
pi@raspberrypi ~ $ clear
pi@raspberrypi ~ $ sudo ./lowbatt.py
Low Battery Detected
Low Battery Detected
Low Battery Detected



Here's the battery monitor script

Code: [Select]
#!/usr/bin/python

"""
A library for reading from a MAX17043 lithium battery fuel gauge over I2C

"""
from __future__ import print_function

import Adafruit_I2C
import os
import subprocess
import argparse
import datetime
import time

I2C_BUS = 1
FUEL_ADDRESS = 0x36

VCELL_REGISTER   = 0x02
SOC_REGISTER     = 0x04
MODE_REGISTER    = 0x06
VERSION_REGISTER = 0x08
CONFIG_REGISTER  = 0x0C
COMMAND_REGISTER = 0xFE

wire = Adafruit_I2C.Adafruit_I2C(0x36, busnum=I2C_BUS)

def writeReset():
    """ reset the fuel guage """
    return writeRegister(COMMAND_REGISTER, 0x00, 0x54)

def writeQuickStart():
    """ set the fuel guage to quick start mode """
    return writeRegister(MODE_REGISTER, 0x40, 0x00)

def writeAlertThreshold(threshold):
    """ set the alert threshold % between 1 and 32 """
    msb, lsb = readRegister(CONFIG_REGISTER)
    threshold = max(1, min(32, threshold)) # threshold between 1 & 32
    threshold = 32 - threshold
    return writeRegister(CONFIG_REGISTER, msb, (lsb & 0xE0) | threshold)

def readVCell():
    """ read the voltage of the battery """
    msb, lsb = readRegister(VCELL_REGISTER)
    value = (msb << 4) | (lsb >> 4)
    return mapValue(value, 0x000, 0xFFF, 0, 50000) / 10000.0

def readSOC():
    """ read the "state of charge" (% remaining) of the battery """
    msb, lsb = readRegister(SOC_REGISTER)
    return msb + lsb/256.0

def readVersion():
    """ read the fuel guage version """
    msb, lsb = readRegister(VERSION_REGISTER)
    return (msb << 8) | lsb

def readCompensatedValue():
    """ read the battery chemistry compensated value """
    msb, lsb = readRegister(CONFIG_REGISTER)
    return msb

def readAlertThreshold():
    """ read the current alert threshold (%) """
    msb, lsb = readRegister(CONFIG_REGISTER)
    return 32 - (lsb & 0x1F)

def readAlert():
    """
    read whether or not the battery is "in alert" / below the alert threshold

    """
    msb, lsb = readRegister(CONFIG_REGISTER)
    return lsb & 0x20

def readRegister(address):
    """ utility function for reading 2 bytes from a register address """
    return wire.readList(address, 2)

def writeRegister(address, msb, lsb):
    """ utility function for writing 2 bytes to a register address """
    return wire.writeList(address, [msb, lsb])

def mapValue(x, in_min, in_max, out_min, out_max):
    """ utility function for mapping a value from one range to another """
    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min

def watch(interval=15, eol_percent=10, max_n=120):
    """
    watch the battery consumption using a modified moving average of the
    state of charge and estimate the time remaining at the current usage.

    """
    prev_soc = None
    diff_mma = 0
    diff_n = 0
    charging = False

    while True:
        # get the current state of charge
        soc = readSOC()
        if prev_soc is None:
            prev_soc = soc

        # compute the difference between the current and previous soc reading
        diff = soc - prev_soc
        if diff <= 0:
            charging = False
        else:
            charging = True

        # compute a modified moving average of the rate of usage
        diff_mma = mma(diff, mma_yesterday=diff_mma, n=diff_n)
        diff_n = min(diff_n + 1, max_n) # only weight max_n observations (this should helps with lar$
        prev_soc = soc

        if diff_mma != 0:
            ttl = ((soc-eol_percent)/-diff_mma)*interval # how many seconds until we reach 10%?
            h, m, s = split_seconds(ttl)
            print("estimated time left: {0}h {1}m {2}s ({3:.2f}%){4}".format(int(h), int(m), int(s),$
            print("timestamp: {0}".format(datetime.datetime.now()))

     if prev_soc is None:
            prev_soc = soc

        # compute the difference between the current and previous soc reading
        diff = soc - prev_soc
        if diff <= 0:
            charging = False
        else:
            charging = True

        # compute a modified moving average of the rate of usage
        diff_mma = mma(diff, mma_yesterday=diff_mma, n=diff_n)
        diff_n = min(diff_n + 1, max_n) # only weight max_n observations (this should helps with lar$
        prev_soc = soc

       if diff_mma != 0:
            ttl = ((soc-eol_percent)/-diff_mma)*interval # how many seconds until we reach 10%?
            h, m, s = split_seconds(ttl)
            print("estimated time left: {0}h {1}m {2}s ({3:.2f}%){4}".format(int(h), int(m), int(s),$
            print("timestamp: {0}".format(datetime.datetime.now()))
            print("threshold: {0}".format(readAlertThreshold()))
            print("alert: {0}".format(readAlert()))
            print("volts: {0}".format(readVCell()))
            print("Battery Remaining: {0:.2f}%".format(readSOC()))

        if (readSOC()) >= 70:
            print("Battery OK: {0:.2f}%".format(readSOC()))
            subprocess.call(['rm /tmp/lowbatt &'], shell=True)
        else:
            print("Battery Low: {0:.2f}%".format(readSOC()))
            subprocess.call(['touch /tmp/battlow & echo "Setting Low Battery Status" &'], shell=True)

        # sleep until the next reading
        time.sleep(interval)

def mma(observation, mma_yesterday=0, n=0):
    """
    Compute the modified moving average for a series of observations.

    Formally:
  print("alert: {0}".format(readAlert()))
            print("volts: {0}".format(readVCell()))
            print("Battery Remaining: {0:.2f}%".format(readSOC()))

        if (readSOC()) >= 70:
            print("Battery OK: {0:.2f}%".format(readSOC()))
            subprocess.call(['rm /tmp/lowbatt &'], shell=True)
        else:
            print("Battery Low: {0:.2f}%".format(readSOC()))
            subprocess.call(['touch /tmp/battlow & echo "Setting Low Battery Status" &'], shell=True)

        # sleep until the next reading
        time.sleep(interval)

def mma(observation, mma_yesterday=0, n=0):
    """
    Compute the modified moving average for a series of observations.

    Formally:

        MMAtoday = (((N-1) * MMAyesterday) + observation) / N

        (which is, in short, an exponential moving average with alpha=1/N)

    """
    if n == 0:
        return observation
    return (((n-1) * mma_yesterday) + observation) / (n)

def split_seconds(seconds):
    """ split seconds into hours, minutes, and seconds """
    seconds = int(seconds)
    if seconds < 0:
        return 0, 0, 0
    hours = seconds/3600
    seconds = seconds % 3600
    minutes = seconds / 60
    seconds = seconds % 60
    return hours, minutes, seconds

def dump():

   """ dump the current state to stdout """
    print("timestamp: {0}".format(datetime.datetime.now()))
    print("version: {0}".format(readVersion()))
    print("compensated: {0}".format(readCompensatedValue()))
    print("threshold: {0}".format(readAlertThreshold()))
    print("alert: {0}".format(readAlert()))
    print("vcell: {0}".format(readVCell()))
    print("soc: {0:.2f}%".format(readSOC()))

if __name__ == "__main__":
    try:
        watch()
    except KeyboardInterrupt:
        print()


Here's the rather simple low battery detection script. I was going to do all this with hardware GPIO pins but this is simpler and more elegant because it doesn't require any more wiring and allows me to use mostly the existing scripts.
As a backup I'll still have hardware level low battery detection which will do a hard shutdown in case of a system crash.

Code: [Select]
#!/usr/bin/python

import os
from time import sleep
import subprocess
import os.path

while True:
    if os.path.isfile('/tmp/battlow'):
        print "Low Battery Detected"
    else:
        print "Battery OK"
    sleep(15)

try:
    while True:
        # do whatever
        sleep(2)

except KeyboardInterrupt:
    print("Exit")
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 01, 2015, 11:13:55 am
I contacted J0rdan Sherer the author of the Fuel library and he was very modest!

He gave me a quick tip that should point me in the right direction below. Thanks J0rdan!

Quote
Thanks for reaching out. I wrote this for a personal project of mine: http://restoringmylibretto.tumblr.com/ and never expected somebody else might want to use it. Otherwise, I probably would have written some better documentation!

Anyway, the script was generally only used as a battery level / "time remaining" estimator. It reads the SOC level from the battery in a loop and computes the estimated time remaining based on a modified moving average of the current battery consumption. As long as consumption was fairly steady, this estimated the time remaining for my project usually at 90% accuracy. I rarely used it to write the values to the MAX17043.

Anyway, if you don't want to use the script as a simple battery monitor, but would rather use it to write the threshold level, you can do that by using the writeThreshold function. You can either modify the script itself to call that function, or import it from another script or the python interactive command. Something as simple as this from another script should work:
import fuel
fuel.writeThreshold(16)

Otherwise, you could set the threshold at the beginning of the watch function.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 03, 2015, 08:22:01 am
The good news is I have all my scripts working now.  The bad news is, I still haven't worked out how to make use of the kill switch feature on the power switch to completely turn power off when battery gets low.

I can either get down to Halt with a clean shutdown or trigger a kill switch hard shutdown, but I'd like to do a kill switch as the last thing before HALT so that I can completely turn the power off.
I've spent soooo much time on just the power side of this, curse you battery powered devices! It's so much simpler when it's just a power switch to mains with a shutdown switch!

Any way here's where Im up to in case any bright spark here has an idea how to achieve what I want.

First a tiny bit more background. (please excuse the untidy code im still learning as I go!)

Im using an Adafruit Push-button Power Switch Breakout on the RPi2B for power on and power off and I have a sparkfun fuel gauge to monitor the LiPo battery. The switch works as intended for normal power on and off, and it has a kill switch feature. If you put 1to3v on the kill switch pin it also shuts off the power.

I'd like to use the kill switch to power off the Pi with the alert pin from the fuel gauge. (this way its also a last line of defence to shut power off if the Pi hangs)
When the battery gets low the fuel gauge alert pin goes from 3.3v to 0 volts. (which is actually the opposite of what I want - it makes sense to work this way though because otherwise it would further flatten he battery) What this means though is that I have to use GPIO pins on the Pi to detect the alert pin going low and then shutdown. 

I have all the scripts working when manually triggered but I cant work out how to trigger the kill switch after the Pi has shutdown or even just before the final halt command.

Is there anyway to pull a GPIO output pin high at shutdown.(just before or even after HALT)
I've tried adding a script to the rc0.d just before HALT.
I moved K10halt to K50halt and added my script as K10poweroff with symlink to the below script, but im guessing I cant use python at this stage of the shutdown.

If there's another way to do this I'd love to know.
I figure worst case I could edit the default pin behaviour in the Pi device tree but Im still new to this stuff and would prefer not to have pins default to an output unless I have no other choice.
Thanks!

Here's my main GPIO button script.

Code: [Select]
#!/usr/bin/env python2.7

from time import sleep
import os
import subprocess
import RPi.GPIO as GPIO

BUTTON1 = 17 # GPIO channel 17 - RestartMC/Shutdown/Reboot
LED1 = 26 # GPIO channel 26 - Power LED
BATTERY1 = 16 # GPIO channel 16 - Low Battery
POWEROFF1 = 22 # GPIO channel 22 - Power off kill switch

GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(LED1, GPIO.OUT, pull_up_down=GPIO.PUD_UP)
GPIO.output(LED1, 1)
GPIO.setup(BATTERY1, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(POWEROFF1, GPIO.OUT, pull_up_down=GPIO.PUD_DOWN)


def button_action(BUTTON1):
    print('Button press = negative edge detected on Button %s'%BUTTON1)
    button_press_timer = 0
    while True:
            if (GPIO.input(BUTTON1) == False) : # while button is still pressed down
                button_press_timer += 1 # keep counting until button is released
            else: # button is released, figure out for how long
                if (button_press_timer > 7) : # pressed for > 10 seconds
                    print "long press > 7 : ", button_press_timer
                    # do what you need to do before halting
   subprocess.call(['sudo reboot &'], shell=True)
                elif (button_press_timer > 3 < 7) : # pressed for > 4<10 seconds
                    print "medium press > 3 < 7 : ", button_press_timer
                    # do what you need to do before rebooting
   subprocess.call(['./RestartMC20.sh & echo "Killing MC20" &'], shell=True)
                elif (button_press_timer > 1 < 3) : # press for > 2 < 4 seconds
                    print "short press > 1 < 3 : ", button_press_timer
                    # do what you need to do before restarting mediacenter20
   subprocess.call(['shutdown -h now "System halted by GPIO action" &'], shell=True)
button_press_timer = 0
            sleep(1)

def battery_monitor(BATTERY1):
#    batt_timer = 0
    while True:
        if (GPIO.input(BATTERY1) == True) : # while batt is ok
         batt_timer = 0
       print "batt Ok"
   else: # batt is low
          print "Battery Low Detected - Checking"
       batt_timer += 1 # keep counting
          if (batt_timer > 60) : # batt low for > 60 seconds
         print "Battery Low For More Than 60 Seconds Shutting Down: "
#    subprocess.call(['shutdown -h now "System halted by Low Battery GPIO action" &'], shell=True)
        sleep(1)

GPIO.add_event_detect(BUTTON1, GPIO.FALLING, callback=button_action, bouncetime=200)
GPIO.add_event_detect(BATTERY1, GPIO.FALLING, callback=battery_monitor, bouncetime=200)
# setup the thread, detect a falling edge on channel 3 and debounce it with 200mSec


# assume this is the main code...
try:
    while True:
        # do whatever
        # while "waiting" for falling edge on port 3
        sleep (2)

except KeyboardInterrupt:
    GPIO.cleanup()       # clean up GPIO on CTRL+C exit
GPIO.cleanup()           # clean up GPIO on normal exit


Here's the battery monitor script
Code: [Select]
#!/usr/bin/python

import os
from time import sleep
import subprocess
import os.path

while True:
    if os.path.isfile('/tmp/battlow'):
        print "Low Battery Detected"
    else:
     print "Battery OK"
    sleep(15)

try:
    while True:
        # do whatever
        sleep(2)

except KeyboardInterrupt:
    print()


Here's the final poweroff script im trying to run just before halt.
Code: [Select]
#!/usr/bin/python

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

POWEROFF = 22

GPIO.setup(POWEROFF, GPIO.OUT, pull_up_down=GPIO.PUD_UP)
GPIO.output(POWEROFF, 1)

Oh and here's the excerpt of my code changes to the fuel gauge script.
Code: [Select]
if (readSOC()) >= 4:
print("Battery OK: {0:.2f}%".format(readSOC()))
subprocess.call(['rm /tmp/lowbatt &'], shell=True)
else:
print("Battery Low: {0:.2f}%".format(readSOC()))
subprocess.call(['touch /tmp/battlow & echo "Setting Low Battery Status" &'], shell=True)


Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: mwillems on May 03, 2015, 08:52:10 am
I have no good advice, but can offer my sympathy.  That exact "reverse-bootstrap" issue is something I grappled with in trying to handle Pi-turn-offs and it's one that the community doesn't have a great solution for even outside of the battery context. 

Ultimately I think trying to script a solution will be a dead-end because if you can still run a script, the OS is still operating, which means the filesystem is still being accessed and the sd card is still running wear-levelling, which means there's still a risk of filesystem corruption.  It's a chicken and egg problem.

One mitigation solution is to make the filesystem read-only and run the OS in RAM (https://wiki.debian.org/ReadonlyRoot).  That will solve half the problem of sdcard corruption (eliminate system writes), so just cutting power without a halt won't be quite as catastrophic.  But that doesn't solve the other half of the problem, which is SD card wear-leveling, and I know of no way to solve that issue without a proper halt.

The only real solutions I can think of involve external hardware/electronic solutions.  For example: I have a powerstrip that senses when power draw on one outlet goes below a certain threshold for more than a second or two, and then closes a relay cutting power to the rest of the strip.  If you could setup a circuit like that which would trigger based on the Pi itself's decreasing powerdraw during a halt, you'd solve your own problem.  Unfortunately, I have no idea how to design such a circuit, but I know it's possible  ;D
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: RoderickGI on May 03, 2015, 09:56:25 pm
When the battery gets low the fuel gauge alert pin goes from 3.3v to 0 volts.

I think MWillems has the solution, sort of. You can't do it in scripts. You have to do it in hardware. It sounds like you need a simple transistor circuit that detects the 3.3v to 0v drop, and sends a pin high to shutdown the Pi via the Kill Pin on the Adafruit Push-button Power Switch Breakout. That is what transistors do.

Unfortunately I'm not an electronics engineer so I can't advise how to actually do that. But I would guess there are a heap of examples on the internet.

Thinking about it though, I would first investigate if there was another pin on the sparkfun fuel gauge that goes high instead of low, or if a small modification would provide such a pin. I would ask the supplier/designer about that.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 04, 2015, 02:01:35 am
Yeah thanks for your input guys, I was already considering I might have to use a relay and/or transistor to trigger the alert pin after shutdown.

There's certainly plenty of examples of this specifically for the Pi but it adds another level of difficulty I was hoping to avoid.

I'll give it one last look tonight to see if I can do it with the current hardware and software, otherwise I'll have to move on to a relay/transistor solution to move forward.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 04, 2015, 08:13:37 am
To keep things simple for now I've made a decision to just use the Fuel Gauge alert pin to shutdown the Pi gracefully and will also reset the Alert pin on the fuel gauge during the shutdown so that when the battery is recharged enough, the Alert pin will already be reset. 

If I read the datasheet correctly, the Alert pin stays low even after a reset until the battery voltage rises above the cutoff threshold, at which time the pin should reset because I have already reset the alert during shutdown.  This should cover the low battery situation unless the Pi crashes.

I'm testing this theory now by running the battery down and resetting the alert before I recharge to see what it does.

The battery really should have a battery protection board on it anyway as the failsafe to protect the battery from over discharging. This way if for any reason the Pi hangs and I haven't noticed the battery can be the final fallback for a shutdown.

Unfortunately the Lipo powerbooster would run the battery down to a dangerous level because it will keep pulling current and run the battery down to 1.8V or less.
The battery I'm currently using doesn't have a protection board because I pulled it from a USB battery pack and I'm not using the original circuit board that came with it.

So the final version will have a battery protection circuit built into the battery anyway as most batteries come with them built in when you order the battery as a component.

Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 05, 2015, 06:05:25 am
I got the battery shutdown script working!

I didn't even need to use a GPIO it's all scripted to take the measurements from the fuel gauge board over the I2C bus.  I've even got it all running in just one script now.

Because I can take accurate battery measurements now I can script actions at any voltage and I can trigger different led flashes for low battery and critical battery as well as the shutdown.
That's next. :) (along with play and pause toggle on the main button now that Bob made media keys work)

------

pi@raspberrypi ~ $ sudo ./gpio.py
Battery OK: 3.8119 volts
Battery OK: 3.8119 volts
Battery OK: 3.8119 volts
Battery Lo: 3.7045 volts - Checking for 20 seconds: 0
Battery Lo: 3.7045 volts - Checking for 20 seconds: 1
Battery Lo: 3.7045 volts - Checking for 20 seconds: 2
Battery Lo: 3.7032 volts - Checking for 20 seconds: 3
Battery Lo: 3.7032 volts - Checking for 20 seconds: 4
Battery Lo: 3.6996 volts - Checking for 20 seconds: 5
Battery Lo: 3.702 volts - Checking for 20 seconds: 6
Battery Lo: 3.702 volts - Checking for 20 seconds: 7
Battery Lo: 3.702 volts - Checking for 20 seconds: 8
Battery Lo: 3.702 volts - Checking for 20 seconds: 9
Battery Lo: 3.702 volts - Checking for 20 seconds: 10
Battery Lo: 3.702 volts - Checking for 20 seconds: 11
Battery Lo: 3.702 volts - Checking for 20 seconds: 12
Battery Lo: 3.7008 volts - Checking for 20 seconds: 13
Battery Lo: 3.7008 volts - Checking for 20 seconds: 14
Battery Lo: 3.7008 volts - Checking for 20 seconds: 15
Battery Lo: 3.6996 volts - Checking for 20 seconds: 16
Battery Lo: 3.6996 volts - Checking for 20 seconds: 17
Battery Lo: 3.6996 volts - Checking for 20 seconds: 18
Battery Lo: 3.6996 volts - Checking for 20 seconds: 19
Battery Lo: 3.6996 volts - Checking for 20 seconds: 20
Battery Low For More Than 20 Seconds Shutting Down:

Broadcast message from root@raspberrypi (Tue May  5 20:45:17 2015):

System halted by Low Battery Alert
The system is going down for system halt NOW!
Battery Lo: 3.6996 volts - Checking for 20 seconds: 21
Battery Low For More Than 20 Seconds Shutting Down:

Broadcast message from root@raspberrypi (Tue May  5 20:45:18 2015):

System halted by Low Battery Alert
The system is going down for system halt NOW!
Battery Lo: 3.6605 volts - Checking for 20 seconds: 22
Battery Low For More Than 20 Seconds Shutting Down:

Broadcast message from root@raspberrypi (Tue May  5 20:45:19 2015):

System halted by Low Battery Alert
The system is going down for system halt NOW!

---------

Here's the cleaned up script with the battery monitor set for 3.2v - my scripting is getting a little tidier. :)

Code: [Select]
#!/usr/bin/env python2.7

from time import sleep
import os
import subprocess
import RPi.GPIO as GPIO
import fuel

BUTTON1 = 17 # GPIO channel 17 - RestartMC/Shutdown/Reboot
LED1 = 26 # GPIO channel 26 - Power LED
#BATTERY1 = 23 # GPIO channel 23 - Low Battery
POWEROFF1 = 22 # GPIO channel 22 - Power off kill switch


GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(LED1, GPIO.OUT, pull_up_down=GPIO.PUD_UP)
GPIO.output(LED1, 1)
GPIO.setup(BATTERY1, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(POWEROFF1, GPIO.OUT, pull_up_down=GPIO.PUD_DOWN)
fuel.writeAlertThreshold(5)


def button_action(BUTTON1):
    print('Button press = negative edge detected on Button %s'%BUTTON1)
    button_press_timer = 0
    while True:
            if (GPIO.input(BUTTON1) == False) : # while button is still pressed down
                button_press_timer += 1 # keep counting until button is released
            else: # button is released, figure out for how long
                if (button_press_timer > 7) : # pressed for > 7 seconds
                    print "long press > 7 : ", button_press_timer
                    # do what you need to do before halting
   subprocess.call(['sudo reboot &'], shell=True)
                elif (button_press_timer > 3 < 7) : # pressed for > 3 < 7 seconds
                    print "medium press > 3 < 7 : ", button_press_timer
                    # do what you need to do before rebooting
   subprocess.call(['./RestartMC20.sh & echo "Killing MC20" &'], shell=True)
                elif (button_press_timer > 1 < 3) : # press for > 1 < 3 seconds
                    print "short press > 1 < 3 : ", button_press_timer
                    # do what you need to do before restarting mediacenter20
   subprocess.call(['shutdown -h now "System halted by GPIO action" &'], shell=True)
button_press_timer = 0
            sleep(1)

def battery_monitor():
    batt_timer = 0
    while True:
     if (fuel.readVCell()) >= 3.2: #check battery voltage
                #print("Battery OK: {0} volts".format(fuel.readVCell()))
                batt_timer = 0
   else: # batt is low
          print "Battery Low: {0} volts".format(fuel.readVCell()), "- Checking for 20 seconds: {0}".format(batt_timer)
       batt_timer += 1 # keep counting
          if (batt_timer > 20) : # batt low for > 20 seconds
         print "Battery Low For More Than 20 Seconds - Shutting Down: "
               subprocess.call(['shutdown -h now "System halted by Low Battery Alert" &'], shell=True)
        sleep(1)

GPIO.add_event_detect(BUTTON1, GPIO.FALLING, callback=button_action, bouncetime=200)
#GPIO.add_event_detect(BATTERY1, GPIO.FALLING, callback=battery_monitor, bouncetime=200)

try:
    while True:
        sleep(5)# sleep and do the battery monitor loop
        battery_monitor()

except KeyboardInterrupt:
    GPIO.cleanup()       # clean up GPIO on CTRL+C exit
GPIO.cleanup()           # clean up GPIO on normal exit

Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 05, 2015, 11:09:36 am
Got my Play/Pause button working. :)

Updated main script
Code: [Select]
#!/usr/bin/env python2.7

from time import sleep
import os
import subprocess
import RPi.GPIO as GPIO
import fuel

BUTTON1 = 17 # GPIO channel 17 - RestartMC/Shutdown/Reboot
LED1 = 26 # GPIO channel 26 - Power LED
#BATTERY1 = 23 # GPIO channel 23 - Low Battery
POWEROFF1 = 22 # GPIO channel 22 - Power off kill switch

GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(LED1, GPIO.OUT, pull_up_down=GPIO.PUD_UP)
GPIO.output(LED1, 1)
#GPIO.setup(BATTERY1, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(POWEROFF1, GPIO.OUT, pull_up_down=GPIO.PUD_DOWN)
fuel.writeAlertThreshold(5)


def button_action(BUTTON1):
    print('Button press = negative edge detected on Button %s'%BUTTON1)
    button_press_timer = 0
    while True:
            if (GPIO.input(BUTTON1) == False) : # while button is still pressed down
                button_press_timer += 1 # keep counting until button is released
            else: # button is released, figure out for how long
                if (button_press_timer > 7) : # pressed for > 7 seconds
                    print "long press > 7 : ", button_press_timer
    subprocess.call(['sudo reboot &'], shell=True)
                elif (button_press_timer > 4 < 7) : # pressed for > 4 < 7 seconds
                    print "medium press > 4 < 7 : ", button_press_timer
    subprocess.call(['./RestartMC20.sh & echo "Killing MC20" &'], shell=True)
                elif (button_press_timer > 2 <= 3) : # press for > 2 <=3 seconds
                    print "short press > 2 < 3= : ", button_press_timer
    subprocess.call(['shutdown -h now "System halted by GPIO action" &'], shell=True)
elif (button_press_timer > 0 < 2) : # pressed for  1 second
                    print "quick press > 0 < 2 : ", button_press_timer
                    subprocess.call(['./xdotoolplay.sh'])
button_press_timer = 0
            sleep(1)

def battery_monitor():
    batt_timer = 0
    while True:
      if (fuel.readVCell()) >= 3.2: #check battery voltage
                #print("Battery OK: {0} volts".format(fuel.readVCell()))
                batt_timer = 0
    else: # batt is low
            print "Battery Low: {0} volts".format(fuel.readVCell()), "- Checking for 20 seconds: {0}".format(batt_timer)
        batt_timer += 1 # keep counting
            if (batt_timer > 20) : # batt low for > 20 seconds
          print "Battery Low For More Than 20 Seconds - Shutting Down: "
                subprocess.call(['shutdown -h now "System halted by Low Battery Alert" &'], shell=True)
        sleep(1)

GPIO.add_event_detect(BUTTON1, GPIO.FALLING, callback=button_action, bouncetime=200)
##GPIO.add_event_detect(BATTERY1, GPIO.FALLING, callback=battery_monitor, bouncetime=200)

try:
    while True:
        sleep(5)# sleep and do the battery monitor loop
        battery_monitor()

except KeyboardInterrupt:
    GPIO.cleanup()       # clean up GPIO on CTRL+C exit
GPIO.cleanup()           # clean up GPIO on normal exit

the play/pause script using xdotool

Code: [Select]
#! /bin/bash

sudo su -c "DISPLAY=:0 xdotool key XF86AudioPlay" pi
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: bob on May 05, 2015, 12:31:18 pm
Got my Play/Pause button working. :)

Updated main script
Code: [Select]
#!/usr/bin/env python2.7

from time import sleep
import os
import subprocess
import RPi.GPIO as GPIO
import fuel

BUTTON1 = 17 # GPIO channel 17 - RestartMC/Shutdown/Reboot
LED1 = 26 # GPIO channel 26 - Power LED
#BATTERY1 = 23 # GPIO channel 23 - Low Battery
POWEROFF1 = 22 # GPIO channel 22 - Power off kill switch

GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(LED1, GPIO.OUT, pull_up_down=GPIO.PUD_UP)
GPIO.output(LED1, 1)
#GPIO.setup(BATTERY1, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(POWEROFF1, GPIO.OUT, pull_up_down=GPIO.PUD_DOWN)
fuel.writeAlertThreshold(5)


def button_action(BUTTON1):
    print('Button press = negative edge detected on Button %s'%BUTTON1)
    button_press_timer = 0
    while True:
            if (GPIO.input(BUTTON1) == False) : # while button is still pressed down
                button_press_timer += 1 # keep counting until button is released
            else: # button is released, figure out for how long
                if (button_press_timer > 7) : # pressed for > 7 seconds
                    print "long press > 7 : ", button_press_timer
    subprocess.call(['sudo reboot &'], shell=True)
                elif (button_press_timer > 4 < 7) : # pressed for > 4 < 7 seconds
                    print "medium press > 4 < 7 : ", button_press_timer
    subprocess.call(['./RestartMC20.sh & echo "Killing MC20" &'], shell=True)
                elif (button_press_timer > 2 <= 3) : # press for > 2 <=3 seconds
                    print "short press > 2 < 3= : ", button_press_timer
    subprocess.call(['shutdown -h now "System halted by GPIO action" &'], shell=True)
elif (button_press_timer > 0 < 2) : # pressed for  1 second
                    print "quick press > 0 < 2 : ", button_press_timer
                    subprocess.call(['./xdotoolplay.sh'])
button_press_timer = 0
            sleep(1)

def battery_monitor():
    batt_timer = 0
    while True:
      if (fuel.readVCell()) >= 3.2: #check battery voltage
                #print("Battery OK: {0} volts".format(fuel.readVCell()))
                batt_timer = 0
    else: # batt is low
            print "Battery Low: {0} volts".format(fuel.readVCell()), "- Checking for 20 seconds: {0}".format(batt_timer)
        batt_timer += 1 # keep counting
            if (batt_timer > 20) : # batt low for > 20 seconds
          print "Battery Low For More Than 20 Seconds - Shutting Down: "
                subprocess.call(['shutdown -h now "System halted by Low Battery Alert" &'], shell=True)
        sleep(1)

GPIO.add_event_detect(BUTTON1, GPIO.FALLING, callback=button_action, bouncetime=200)
##GPIO.add_event_detect(BATTERY1, GPIO.FALLING, callback=battery_monitor, bouncetime=200)

try:
    while True:
        sleep(5)# sleep and do the battery monitor loop
        battery_monitor()

except KeyboardInterrupt:
    GPIO.cleanup()       # clean up GPIO on CTRL+C exit
GPIO.cleanup()           # clean up GPIO on normal exit

the play/pause script using xdotool

Code: [Select]
#! /bin/bash

sudo su -c "DISPLAY=:0 xdotool key XF86AudioPlay" pi

Cool!
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 05, 2015, 10:28:28 pm
I'm just about ready to start building up another case to send across to you to play with now.

I have all the electronics and scripting working.

Im ready to move on to the MKIII prototype now but I could send you one as it is now if you don't mind hooking up your own GPIO wires and not having a back panel on it and no HDMI.
Everything else would be pre wired and mounted.

On the next prototype I'd just like to clean up the internal wiring with possibly a custom PCB with a GPIO socket to remove 99% of the internal wiring and organise a proper mounting system for all the boards.
I still have to work out what to do with the HDMI, although to be honest I haven't missed it as im using either a DAC or Bluetooth or Wifi anyway. The guys that promised me the HDMI cable haven't got back to me.
 
I've also found another perfect case for a desktop version of it. (still with a battery if needed)
It's a little bit smaller than the FiiO desktop DAC you can see in my photos and yo can get it all in black or with the silver front/back.

I may also be able to find a smaller case with the same design as this one for a more compact portable version.

(https://public.dm2301.livefilestore.com/y2pXYQgwM4fPyvc_An7ZmkwHcMNIcG9wXHGjwxglblS-aluaO38Fd8QUJakFfrLI2NvUq8iQLKSQKGGuL23OTZb8fx8s6gOSsoOZk8vWplWAU7Pkxjq1NzFSzrO0xSI9KiyHZR036seRUJvz6F4MQKM1w/%24%28KGrHqJ%2C%21lQFIetijf%2CKBSNtDLJ1q%21~~60_57.jpg)

(https://public.dm2301.livefilestore.com/y2pJhrBL3HcwRp3Hpm8qM-GxOtB5GMP26ItzVTJVq5Q6r9iZX1GE-nZQqLiftZuS7PT42c507pmiPoLlFlUeNmqI7qXlVF0R4DhPou7qvXVmgTrkxEEjidiiZkxH_I7w7HOdZI4VYpPHXETLZPd-6J1mw/%24T2eC16d%2C%21yUFIbnYEKcUBSNtDRLVvg~~60_57.jpg)

Bob let me know if you're keen for a MKII prototype and I can get one setup over the next week.


Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 07, 2015, 07:27:19 am
BTW the case above is longer so it will easily have room for a quality I2C DAC to be included and a front OLED touch display. :)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 07, 2015, 09:17:56 pm
I'm working on a 3D model this weekend to 3D print a thin internal shell inside the case that the circuit boards will mount to that also forms the rear panel with cutouts for the ports.

I should have a print done in the next week.

Once that's done I can make a few more prototypes if anyone wants to pay for the cost of materials and parts.

Then I'll be starting the next prototype in the new above case with an OLED display on the front with an I2C DAC.  
The next prototype will also be the basis for a Pi Speaker running MC20 if all goes well.  ;D

Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 07, 2015, 10:52:36 pm
I dropped into my local electronics store over lunch today and picked up these... :)

A tall-boy Pi brick case, a Mosfet transistor to create the main power kill switch and 128x128 OLED colour display.

Time for a new thread and a new adventure! :)

I got an extra case to build another type II prototype as well.

(https://public.dm2301.livefilestore.com/y2pg3r_Z64nwGpFh4f9TZtQrrAJufYMnO3o-dxGaqgGwO2ZWPxKh_W2Upvkgo8H703tzCMI_ibuX_0jfEQHXdbnQ31_hCnx_r5ql5WRSZ5EZbgi0PdqI5yCreEBSrDusJ1HSVUfOYvI6YbXXe4G40RwBg/20150508_034632970_iOS.jpg?psid=1)


Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: gvanbrunt on May 10, 2015, 09:00:37 pm
Very cool stuff. I've just embarked on my first Pi projects and came across this. I'm looking to provide a "Media Network" for my new Travel Trailer (Caravan for those of you on the other side of the ocean). What I have so far is:

1 Pi will work as an Airport Express copy with an audio jack to the receiver in the trailer.
1 Pi will work as a router for the Wifi network in general. If internet is available in the park it will be available or I can just use it to "pump" media around.
1 NAS that I can store music and movies on.
Both run on 12V from the RV battery so I can play audio without having to run a Generator. Both also run Arch so it should boot really fast. The NAS isn't going to run on 12V so that part would require the generator, but I have a lot on my phones already. Unless I can figure out a good way to run a Synology on 12V that is...

With this part I can sit by the fire and play music from our phones etc. Bluetooth has always been a bit dodgy at that range. Wifi will hopefully make that smoother.

I also have to Roku 2's that hooked up to the TVs. Again we can use push video from the phones to the Roku's.

Now what I eventually want to do, is have a few MC clients around hooked up to an MC server. That part is still a bit of grey area, so I will be looking at this build with interest. Keep up the great work.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 11, 2015, 05:59:05 am
Very cool stuff. I've just embarked on my first Pi projects and came across this. I'm looking to provide a "Media Network" for my new Travel Trailer (Caravan for those of you on the other side of the ocean). What I have so far is:

1 Pi will work as an Airport Express copy with an audio jack to the receiver in the trailer.
1 Pi will work as a router for the Wifi network in general. If internet is available in the park it will be available or I can just use it to "pump" media around.
1 NAS that I can store music and movies on.
Both run on 12V from the RV battery so I can play audio without having to run a Generator. Both also run Arch so it should boot really fast. The NAS isn't going to run on 12V so that part would require the generator, but I have a lot on my phones already. Unless I can figure out a good way to run a Synology on 12V that is...

With this part I can sit by the fire and play music from our phones etc. Bluetooth has always been a bit dodgy at that range. Wifi will hopefully make that smoother.

I also have to Roku 2's that hooked up to the TVs. Again we can use push video from the phones to the Roku's.

Now what I eventually want to do, is have a few MC clients around hooked up to an MC server. That part is still a bit of grey area, so I will be looking at this build with interest. Keep up the great work.

That sounds great!
Thanks for the encouragement.
Sounds like another marketing opportunity for a portable media server/player. The "RV/trailer/camper/caravan" market.

The 1 Pi can work as both airport express and router at the same time connected to your receiver in the trailer.
You can get pretty cheap 12V to 240V converters that would work for the NAS or you can work out what voltage / current the NAS uses and buy a 12V DC to DC converter which would be more efficient.
What size is the NAS? You could get a smaller more compact USB 6TB drive that should run fine of 12V. http://www.computeralliance.com.au/6tb-wd-3.5-usb-3.0-my-book-external-hdd-pn-wdbfjk0060hbk-aesn

BTW the JRiver Id classic runs off 12V also and supports video which the Pi does not at this stage.

Inverters (not sure what voltage you're on but just search for 12v to 120V 150W if your on 120V)

Example Cheap 12v to 230V 150W $50
http://www.jaycar.com.au/Power-Products-Electrical/Power-Conversion-%26-Transformation/DC-AC-Inverters/150W-Can-Sized-Power-Inverter-with-2-1A-USB-Output/p/MI5127

Pure sinewave 360W inverter (sinewave is required for some devices to work properly) $270
http://www.jaycar.com.au/Power-Products-Electrical/Power-Conversion-%26-Transformation/DC-AC-Inverters/360-Watt-12VDC-to-230VAC-Pure-Sine-Wave-Inverter/p/MI5702

Cheaper 600W higher powered modified sinewave inverter $130 (NAS should be fine on this or the even cheaper $50 one)
http://www.jaycar.com.au/Power-Products-Electrical/Power-Conversion-%26-Transformation/DC-AC-Inverters/600W-%281500W-Surge%29-12VDC-to-230VAC-Electrically-Isolated-Inverter/p/MI5108




Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: stevemac on May 11, 2015, 06:18:14 am

BTW the JRiver Id classic runs off 12V also and supports video which the Pi does not at this stage.


We travelled last year with two kids.  Had my daughter's NUC (I3) running JRiver & a 2TB drive set-up in the car.  It was serving audio to the adults up front and two different movies to the rear (with infrared screens / headphones).  It worked a treat.  The NUC, HDD & screens all ran of a clean 12VDC supply (http://www.mini-box.com/DCDC-USB-200?sc=8&category=981 (http://www.mini-box.com/DCDC-USB-200?sc=8&category=981)).  We will repeat the setup for any future trips - both car & camper trailer.

Steve
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 11, 2015, 06:33:07 am
Yeah I was running the Id in my car for a few month too prior to the Pi. 
Now the Pi travels everywhere with me, even into the office and friends place to share my music on a decent DAC with them.

I have it fully integrated with the Car BT system via my iPhone. The Id or Pi can stream audio via wifi hotspot on the iPhone with JRemote which then pushes it via an AVRCP BT compliant receiver in the car which is fully integrated with my head unit, steering wheel controls and driver display unit.  The only thing I cant do on the car head unit is browse the library but it's way too slow to navigate anyway compared to the iPhone.  I can even use SIRI to search for stuff in JRemote by pushing the microphone key while in the search box in JRemote.

I should do another updated video of it using the Pi.
If you look at my youtube channel you'll see the original Id demos in the car.
https://www.youtube.com/watch?v=6HFUq7QgnvQ



Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: JimH on May 11, 2015, 06:50:01 am
Our fellow Minnesotan, Dave, built himself a car computer in 2006.  He visited JRiver once.

http://yabb.jriver.com/interact/index.php?topic=13134.0
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 11, 2015, 06:56:20 am
Our fellow Minnesotan, Dave, built himself a car computer in 2006.  He visited JRiver once.

http://yabb.jriver.com/interact/index.php?topic=13134.0

Wow how things have changed. :)
I looked at doing a screen mod to my factory system to make a touch display with native JRiver theatre view via HDMI from a NUC but it's more trouble than it's worth at the moment while Theatre View isn't as touch friendly as JRemote.  I've sourced all the components to do it though and may still do it now that standard view is touch friendly. :)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: gvanbrunt on May 11, 2015, 09:47:35 am
The 1 Pi can work as both airport express and router at the same time connected to your receiver in the trailer.

Yes, but in my case it is a matter of location and signal. Where the "Airport" is going may not have the best signal, and its a tight spot so an antenna for the wifi is out. The router part will go somewhere else and will have an external antenna with a cable so I can put it pretty much wherever I need it.

You can get pretty cheap 12V to 240V converters that would work for the NAS or you can work out what voltage / current the NAS uses and buy a 12V DC to DC converter which would be more efficient.
What size is the NAS? You could get a smaller more compact USB 6TB drive that should run fine of 12V. http://www.computeralliance.com.au/6tb-wd-3.5-usb-3.0-my-book-external-hdd-pn-wdbfjk0060hbk-aesn

Yah, I have a few inverters, but I have to see what the draw on the NAS is. Probably fairly hefty. Still researching that part. Don't want to eat up the juice on the batteries too much. Don't want to break the bank either. SSD's are the way to go power wise, but my wallet can't take the hit, even for a TB of SSD storage.. :) Going to look at what people have done with cars. Might be some info. Ideally I'd run it right off the 12V, but I might need a power conditioner. I know there are some car Power Supplies that put out 12V and 5V suitable for a computer. But that has one draw back: I'm hoping to be able to take the NAS home occasionally and if I modify it to run off straight 12V then I have to have the internal supply available for that function.

Or, if I'm feeling really crazy, I might just make a NAS out of another Pi.... I actually like that idea.

BTW the JRiver Id classic runs off 12V also and supports video which the Pi does not at this stage.

Yes, but that is cheating - there is no hacking and cobbling it together... :)

At any rate, this is going to be an ongoing project. I'm going to post something as I go along. Most of the stuff has been ordered. My biggest concern is going to be SD card corruption, so I'm going to have to do some research there.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: gvanbrunt on May 11, 2015, 09:52:44 am
We travelled last year with two kids.  Had my daughter's NUC (I3) running JRiver & a 2TB drive set-up in the car.  It was serving audio to the adults up front and two different movies to the rear (with infrared screens / headphones).  It worked a treat.  The NUC, HDD & screens all ran of a clean 12VDC supply (http://www.mini-box.com/DCDC-USB-200?sc=8&category=981 (http://www.mini-box.com/DCDC-USB-200?sc=8&category=981)).  We will repeat the setup for any future trips - both car & camper trailer.

Steve

Hey that is probably exactly what I want for the NAS. Thanks for the Tip.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: gvanbrunt on May 11, 2015, 09:57:22 am
BTW, I forgot to mention for prototyping Ponoko https://www.ponoko.com/ (https://www.ponoko.com/) is a great resource. If you can mock stuff up using the free SketchUp then you can have them make you a perfect box/panel/widget via 3d printing.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 12, 2015, 07:40:25 am
I just saw my original list over in my AirPlay thread and thought it would be interesting to check off the list. :)

It's now a bit out of order....

To Quote myself...

My evil plan.. (was and nearly complete - haha haha)

Create a powered speaker with:
For Phase 1

Done - MC on Pi  
Done - Shairport-sync on Pi
Done - Spotify connect on Pi
Done - Bluetooth on Pi

Working on it - High quality DAC on Pi
Working on it - Add Amp module
Working on it - Add mains power
Done - Add an internal rechargeable battery
Create a stereo wireless pair with 3 pole switches

Working on it - Get all that working in a prototype with some spare speakers I have.

Phase 2
Possibilities yet to be explored..
Working on it now - Add a basic display for track info, source playing etc  
Done - Add playback controls to the speaker
Done - Enable BT remote control
Try and enable loopback to use MC DSPs.

Phase 3
Combine the working parts into my own speaker design
Sell the design to Jim Smiley
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: gvanbrunt on May 12, 2015, 09:21:10 am
I know there has been some discussion here on SD card corruption from a bad shut down, but is there any advice anyone can offer on avoiding that?
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: mwillems on May 12, 2015, 09:32:22 am
I know there has been some discussion here on SD card corruption from a bad shut down, but is there any advice anyone can offer on avoiding that?

Making sure the Pi doesn't lose power without a shutdown is the only surefire method.  Batteries or a UPS (which is just a bigger battery) are the "A" answer.

Mounting the filesystem read-only will solve half the problem, but won't resolve issues from a power off during wear-leveling (which happens at the firmware level).  I know of no method to prevent wear-leveling related corruption.  If you know you'll have a network connection you can try running it with a netboot (with only the bootloader, kernel, and supporting files on the Pi).  But that just reduces your "attack surface," and doesn't solve the problem.

FWIW, I've had several dozen "dirty" power-offs with my Pis.  I've gotten a corrupted SD card (non-bootable) twice.  So in my (admittedly anecdotal) experience my failure rate is about 3 or 4%.  You wouldn't want to have a "dirty" power down by default, but occasional interruption is not likely to be fatal. 

For anything that's supposed to be appliance-like or work in a production setting you'll need a battery.  For other applications, if you keep a "dd" image of your working configuration, you can be back up and running in ten minutes (once you figure out it's failed, etc.).
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: gvanbrunt on May 12, 2015, 02:06:02 pm
Hmm, food for thought. I know you can also move part of the OS to USB similar to what you suggested for the network boot. That is one option that may be a good one for me.

Are there any "add ons" that can power down the pi on low power? Or perhaps there is something that allows you to remotely power up and down?
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: stevemac on May 12, 2015, 04:21:45 pm
Are there any "add ons" that can power down the pi on low power? Or perhaps there is something that allows you to remotely power up and down?

I'm looking at  https://www.kickstarter.com/projects/1895460425/pijuice-a-portable-project-platform-for-every-rasp/video_share (https://www.kickstarter.com/projects/1895460425/pijuice-a-portable-project-platform-for-every-rasp/video_share).  From that site

Quote
The real time clock (RTC) on board will let your Pi know what time it is even with no power input or internet connection. Alongside this is a micro-controller (MCU) chip which together will manage soft shut down functionality and a true low power deep sleep state and intelligent start up. 

You will be able to always keep track of the charge levels with the built in tri-coloured RGB LEDs, and since the PiJuice will use up to just five of your GPIO pins (just power and I2C), the rest are free to diversify your project even more. The stacking header allows you to continue to use your existing HATs and add ons with PiJuice

Steve
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 12, 2015, 11:01:00 pm
I rebuilt my Pi image from scratch today in just under 1hr including re-installing all necessary packages and scripts.  At least I know I can rebuild it now!
(thanks to my notes and scripts stored on interact) :)

I stayed on 3.18.7-v7+ this time though as I was getting strange USB DAC problems.
With a clean install everything is back to normal and stable again. I installed MC20.0.101 from the new repository.

Time to take a backup!



Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: mwillems on May 13, 2015, 08:15:36 am
I rebuilt my Pi image from scratch today in just under 1hr including re-installing all necessary packages and scripts.  At least I know I can rebuild it now!
(thanks to my notes and scripts stored on interact) :)

I stayed on 3.18.7-v7+ this time though as I was getting strange USB DAC problems.
With a clean install everything is back to normal and stable again. I installed MC20.0.101 from the new repository.

Time to take a backup!

The second time I had to rebuild a pi image for my home VPN, I did a disk image  ;D.  I wish I had learned the wonders of dd earlier in life. It's stupid easy to create disk images with it, and even easier to re-flash images. 

Semi-related: in all my Pi backing up and re-flashing, my favorite thing I learned last year was that the "cp" command will flash an image if you target a device instead of a partition! 
 
Code: [Select]
cp image.img /dev/sda1 #this copies the image file onto the filesystem on the partition
cp image.img /dev/sda #this flashes the image onto the device clobbering whatever partitions are on the device and replacing them

I'm sure most linux/unix vets already knew this, but it seemed impossibly neat when I stumbled across it.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: gvanbrunt on May 13, 2015, 09:16:23 am
Actually didn't know that about cp. Never really dealt with images before in linux, so great tip!
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: mwillems on May 13, 2015, 09:23:03 am
It's the logical conclusion of the "everything is a file" concept in unix apparently. 

Most folks I've talked to still recommend using dd because it's more consistently implemented across the unixes and is more flexible, but in a normal linux environment I've used the cp method on a few sd cards and it worked like a champ.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 13, 2015, 11:16:09 am
I just setup a network backup mountpoint on my main machine. Backups at 15MB/s over wifi

I made a backup folder called  /media/backups on the Pi
I made a backup folder called /PiBackups on my server

Added this to the fstab by running

sudo nano /etc/fstab

//yourwindowsIP/yourfolder/PiBackups/media/backups cifs user=yourusername,password=yourpassword,uid=1000,gid=1000,iocharset=utf8 0 0

Then to mount it run

sudo mount -a

then run this to back it up

sudo dd if=/dev/mmcblk0 of=/media/backups/backup1.img bs=512k


Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: mwillems on May 13, 2015, 11:22:51 am
I just setup a network backup mountpoint on my main machine. Backups at 15MB/s over wifi

I made a backup folder called  /media/backups on the Pi

Added this to the fstab by running sudo nano /etc/fstab


//yourwindowsIP/yourfolder/PiBackups /media/backups cifs user=yourusername,password=yourpassword,uid=1000,gid=1000,iocharset=utf8 0 0

Then run sudo mount -a to mount it

then run this to back it up

sudo dd if=/dev/mmcblk0 of=/media/backups/backup1.img bs=512k

You probably already know this, but unless your main pi filesystem is mounted read only that method will produce unpredictable results.  dd'ing a live filesystem is a no-no because files can be written during the disk image which can lead to file corruption and/or the corruption of the image.  Even with no other user initiated activity there's a steady stream of writes happening, and given that files are often fragmented across a medium, you can get really unpredictable results with a live disk using the kind of sector by sector copy that dd does.  I tried to live-dd a pi sd card once and got an unbootable image for my trouble.  

The conventional wisdom is to remount the partitions you're dding as read-only first (easier said than done without booting from a USB stick or something), or (much easier) dd the sd card on another machine when entirely unmounted.  For reliable live backups you have to use the filesystem level tools like rsync or cp.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 13, 2015, 11:29:47 am
yeah I'll test it out. I've shutdown most services.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: mwillems on May 13, 2015, 11:36:16 am
Just be aware that it may still boot but have other "silent" file corruption.  Or it may be fine.  There's really no way to know what you're going to get out of it, and that uncertainty is why it's not a great backup choice.  There might be a way to verify the resulting image though through SHA summing or something like that (I haven't looked at it hard).

The nice thing about pi's is that you can "take the drive out" in about five seconds unlike a conventional hdd. Doing a dd backup of a 3.5 inch drive is usually labor intensive enough that I just boot to a live cd and do it that way (or find a way to use rsync instead).  
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: gvanbrunt on May 13, 2015, 12:31:05 pm
I'm looking at  https://www.kickstarter.com/projects/1895460425/pijuice-a-portable-project-platform-for-every-rasp/video_share (https://www.kickstarter.com/projects/1895460425/pijuice-a-portable-project-platform-for-every-rasp/video_share).  From that site

That looks awesome for creating a "set and forget" device like I plan. I'll be keeping an eye on that when the production units start selling...
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 13, 2015, 11:11:04 pm
Just be aware that it may still boot but have other "silent" file corruption.  Or it may be fine.  There's really no way to know what you're going to get out of it, and that uncertainty is why it's not a great backup choice.  There might be a way to verify the resulting image though through SHA summing or something like that (I haven't looked at it hard).

The nice thing about pi's is that you can "take the drive out" in about five seconds unlike a conventional hdd. Doing a dd backup of a 3.5 inch drive is usually labor intensive enough that I just boot to a live cd and do it that way (or find a way to use rsync instead).  

Yeah except for mine when it's in the case, I cant get to the SD card.

I installed dcfldd and pv today so now I can see progress for the backup. dcfldd also has a verify option.
Cloning directly to another SD card in a USB reader it's 3 times slower than over the network. (6MB/s vs 15MB/s) go figure.


I ran:
time sudo pv -tpreb /dev/mmcblk0 | sudo dcfldd of=/dev/sdb

500736 blocks (15648Mb) written.15.3GB 0:44:38 [4.92MB/s] [=====================================>                     
500992 blocks (15656Mb) written.15.3GB 0:44:40 [5.45MB/s] [=====================================>                     
501248 blocks (15664Mb) written.15.3GB 0:44:41 [5.29MB/s] [=====================================>                     
501504 blocks (15672Mb) written.15.3GB 0:44:42 [6.27MB/s] [=====================================>                     
501760 blocks (15680Mb) written.15.3GB 0:44:44 [6.12MB/s] [=====================================>                     
502016 blocks (15688Mb) written.15.3GB 0:44:45 [6.25MB/s] [=====================================>                     
502272 blocks (15696Mb) written.15.3GB 0:44:47 [6.12MB/s] [=====================================>                     
502528 blocks (15704Mb) written.15.3GB 0:44:48 [6.25MB/s] [=====================================>                     
502784 blocks (15712Mb) written.15.3GB 0:44:49 [5.12MB/s] [=====================================>                     
503040 blocks (15720Mb) written.15.4GB 0:44:51 [6.25MB/s] [=====================================>                     
503296 blocks (15728Mb) written.15.4GB 0:44:52 [6.25MB/s] [=====================================>                     
503552 blocks (15736Mb) written.15.4GB 0:44:53 [ 5.5MB/s] [=====================================>                     
503808 blocks (15744Mb) written.================================>                                     ] 51% ETA 0:41:54


Will take about 1.5hrs to backup 32GB card. Time to go back to 8GB cards. :) (I already had 32GB cards)

I checked out rpi-clone too but it doesn't support noobs.  Nearly time I moved on from noobs now anyway to take a look at Arch and see which I prefer.

rpi-clone uses rsync and can do incremental and resize up or down to different size SD cards so I think it's probably worth switching from noobs just for that anyway.
Backups would be much quicker too.

https://github.com/billw2/rpi-clone




Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 14, 2015, 12:16:21 am
backup worked. swapped cards over and booted straight in no filesystem errors and everything works.

29.7GB 1:27:16 [5.81MB/s] [=============================================================================================>] 100%

973968+0 records in
973968+0 records out

real    87m39.520s
user    0m37.480s
sys     9m42.310s


Off to potter with Arch Arm Linux...
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: mwillems on May 14, 2015, 07:42:18 am
Have fun with Arch  ;D  I love it and use it whenever I can justify it.

Some people think it's not be a good fit for an appliance, but I've had moderately good luck in my own applications over an extended period.  I'm interested in what you think.  There are some things about it that are a definite advantage (super minimal install with no cruft you don't need), but the rolling release will occasionally break things and it's not always easy to roll back to older packages (unless you have them cached).  You can always not update, but that leaves security issues open (and partial upgrades are possible but unsupported), etc.  

I've been running two Pi's on arch arm in my house for cseveral months.  I only had a few issues that I've had to fix, but for one of them I did need physical access to the box (it was a wifi issue introduced by a new version of WPA supplicant, which effectively borked automatic wifi functioning, so I had to hook up a monitor to fix it).  

Let me know if you hit any snags or want to swap best practices.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: mwillems on May 14, 2015, 07:54:41 am
Yeah except for mine when it's in the case, I cant get to the SD card.

I installed dcfldd and pv today so now I can see progress for the backup. dcfldd also has a verify option.
Cloning directly to another SD card in a USB reader it's 3 times slower than over the network. (6MB/s vs 15MB/s) go figure.


I ran:
time sudo pv -tpreb /dev/mmcblk0 | sudo dcfldd of=/dev/sdb

500736 blocks (15648Mb) written.15.3GB 0:44:38 [4.92MB/s] [=====================================>                     
500992 blocks (15656Mb) written.15.3GB 0:44:40 [5.45MB/s] [=====================================>                     
501248 blocks (15664Mb) written.15.3GB 0:44:41 [5.29MB/s] [=====================================>                     
501504 blocks (15672Mb) written.15.3GB 0:44:42 [6.27MB/s] [=====================================>                     
501760 blocks (15680Mb) written.15.3GB 0:44:44 [6.12MB/s] [=====================================>                     
502016 blocks (15688Mb) written.15.3GB 0:44:45 [6.25MB/s] [=====================================>                     
502272 blocks (15696Mb) written.15.3GB 0:44:47 [6.12MB/s] [=====================================>                     
502528 blocks (15704Mb) written.15.3GB 0:44:48 [6.25MB/s] [=====================================>                     
502784 blocks (15712Mb) written.15.3GB 0:44:49 [5.12MB/s] [=====================================>                     
503040 blocks (15720Mb) written.15.4GB 0:44:51 [6.25MB/s] [=====================================>                     
503296 blocks (15728Mb) written.15.4GB 0:44:52 [6.25MB/s] [=====================================>                     
503552 blocks (15736Mb) written.15.4GB 0:44:53 [ 5.5MB/s] [=====================================>                     
503808 blocks (15744Mb) written.================================>                                     ] 51% ETA 0:41:54


Will take about 1.5hrs to backup 32GB card. Time to go back to 8GB cards. :) (I already had 32GB cards)

I checked out rpi-clone too but it doesn't support noobs.  Nearly time I moved on from noobs now anyway to take a look at Arch and see which I prefer.

rpi-clone uses rsync and can do incremental and resize up or down to different size SD cards so I think it's probably worth switching from noobs just for that anyway.
Backups would be much quicker too.

https://github.com/billw2/rpi-clone

dcfldd is a neat utility, good find! 

Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 15, 2015, 10:09:14 am
Have fun with Arch  ;D  I love it and use it whenever I can justify it.

Some people think it's not be a good fit for an appliance, but I've had moderately good luck in my own applications over an extended period.  I'm interested in what you think.  There are some things about it that are a definite advantage (super minimal install with no cruft you don't need), but the rolling release will occasionally break things and it's not always easy to roll back to older packages (unless you have them cached).  You can always not update, but that leaves security issues open (and partial upgrades are possible but unsupported), etc.  

I've been running two Pi's on arch arm in my house for cseveral months.  I only had a few issues that I've had to fix, but for one of them I did need physical access to the box (it was a wifi issue introduced by a new version of WPA supplicant, which effectively borked automatic wifi functioning, so I had to hook up a monitor to fix it).  

Let me know if you hit any snags or want to swap best practices.


Hmmm not sure Im sold on Arch as I feel like I'm having to learn more than I wanted too just to have a running system.
I feel like I've gone back to the 80's with DOS2.0.  Having said that, knowing DOS and command line had it's benefits in years gone by. 

I'll stick at it for a while until something I want to do doesn't work or takes too long to work out.  It's certainly a fast lean distribution well suited to the Pi. 
It's also pushing my Linux knowledge faster than Debian was.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: mwillems on May 15, 2015, 10:20:59 am
I'll stick at it for a while until something I want to do doesn't work or takes too long to work out.  It's certainly a fast lean distribution well suited to the Pi.  
It's also pushing my Linux knowledge faster than Debian was.

That's exactly it; I learned more about linux just setting up Arch and running for two weeks than I learned with Debian over a year, and I'm now much more comfortable when things go pear-shaped or I need to script around something.  I still use debian when I need something to "just work" (my server runs on Jessie for example), but running Arch has made me a much better Debian sysadmin  ;D
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on May 17, 2015, 11:52:08 pm
I'm a bit behind on where I planned to be because of diversions with Arch and other family commitments over the past week but I did get another case built over the weekend with backpanel cutouts on the case.

A couple of my measurements were slightly out for the back panel but it looks much better with a back panel and none of the extra holes from trying different switches and components from earlier configurations! :)

This week I'll finish the 3D printed model for the internal mounting shell and start designing the circuit board to simplify internal wiring and connection to the Pi.
I'll then do another revision of the internal shell once I've made the new circuit board.

(https://public.dm2301.livefilestore.com/y2pgQKHKFAtYeYM8fnmvEd6hJn0hpD8Mv8ehdLHQs0S3fmZlQ_fakJ7B-67i9zQjhx15aFZlkie75fsiCj-NoaHruenGHb_uTjLZiZE8cG-JH3gN4nyNJe7hAir0A7c44Sj2NFPseCSGNCfrYk2nyOVwA/20150518_044907831_iOS.jpg)

(https://public.dm2301.livefilestore.com/y2p1Rq7NgqSXKGhje1BPZWf88UfygEP9PM3q0Igyf_j-O6B_0jsr0yPplrRx3K-wie2B8Y9IRyT4rfcBO5-KY4ckJrlED2G89IOUevPcsDGwMjO9Uw4H3c3YD_J4EWV8ORWt6va9vl2iq0uYpLMjQ8Shg/20150518_044932774_iOS.jpg)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on August 13, 2015, 06:43:59 am
Hi all, The 2TB Seagate slim internal drive died tonight with medium errors. :(

I tried to recover with a few different tools in Linux and windows but shes gonski.

I did drop it when it was turned off a few weeks back and I'd been getting a few read errors.
It's been heavily used every day for several months now.

Code: [Select]
536.294955] usb-storage 1-1.5:1.0: USB Mass Storage device detected
[  536.295952] scsi host2: usb-storage 1-1.5:1.0
[  537.292227] scsi 2:0:0:0: Direct-Access     Seagate  BUP Slim SL      0302 PQ: 0 ANSI: 6
[  537.293784] sd 2:0:0:0: Attached scsi generic sg0 type 0
[  537.296403] sd 2:0:0:0: [sda] Spinning up disk...
[  538.301071] ..ready
[  539.311620] sd 2:0:0:0: [sda] 3907029167 512-byte logical blocks: (2.00 TB/1.81 TiB)
[  539.578285] sd 2:0:0:0: [sda] Write Protect is off
[  539.578309] sd 2:0:0:0: [sda] Mode Sense: 4f 00 00 00
[  539.578820] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[  539.637068] Alternate GPT is invalid, using primary GPT.
[  539.637144]  sda: sda1
[  539.639718] sd 2:0:0:0: [sda] Attached SCSI disk
[  543.300629] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  543.300655] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  543.300668] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  543.300684] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 90 a8 00 00 f0 00
[  543.300697] blk_update_request: critical medium error, dev sda, sector 6197416
[  546.162195] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  546.162236] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  546.162248] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  546.162262] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 70 00 00 01 00
[  546.162275] blk_update_request: critical medium error, dev sda, sector 6197616
[  546.162290] Buffer I/O error on dev sda1, logical block 6195568, async page read
[  549.334784] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  549.334819] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  549.334831] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  549.334848] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 71 00 00 01 00
[  549.334861] blk_update_request: critical medium error, dev sda, sector 6197617
[  549.334876] Buffer I/O error on dev sda1, logical block 6195569, async page read
[  552.207879] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  552.207917] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  552.207931] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  552.207946] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 72 00 00 06 00
[  552.207958] blk_update_request: critical medium error, dev sda, sector 6197618
[  552.207972] Buffer I/O error on dev sda1, logical block 6195570, async page read
[  552.207991] Buffer I/O error on dev sda1, logical block 6195571, async page read
[  552.208002] Buffer I/O error on dev sda1, logical block 6195572, async page read
[  552.208013] Buffer I/O error on dev sda1, logical block 6195573, async page read
[  552.208024] Buffer I/O error on dev sda1, logical block 6195574, async page read
[  552.208034] Buffer I/O error on dev sda1, logical block 6195575, async page read
[  555.147493] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  555.147530] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  555.147542] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  555.147558] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 70 00 00 01 00
[  555.147571] blk_update_request: critical medium error, dev sda, sector 6197616
[  555.147586] Buffer I/O error on dev sda1, logical block 6195568, async page read
[  557.920742] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  557.920781] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  557.920794] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  557.920809] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 71 00 00 01 00
[  557.920823] blk_update_request: critical medium error, dev sda, sector 6197617
[  557.920836] Buffer I/O error on dev sda1, logical block 6195569, async page read
[  560.915904] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  560.915944] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  560.915957] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  560.915973] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 72 00 00 06 00
[  560.915986] blk_update_request: critical medium error, dev sda, sector 6197618
[  560.916001] Buffer I/O error on dev sda1, logical block 6195570, async page read
[  560.916020] Buffer I/O error on dev sda1, logical block 6195571, async page read
[  560.916031] Buffer I/O error on dev sda1, logical block 6195572, async page read
[  560.916044] Buffer I/O error on dev sda1, logical block 6195573, async page read
[  560.916055] Buffer I/O error on dev sda1, logical block 6195574, async page read
[  560.916065] Buffer I/O error on dev sda1, logical block 6195575, async page read
[  563.744589] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  563.744616] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  563.744628] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  563.744644] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 70 00 00 01 00
[  563.744656] blk_update_request: critical medium error, dev sda, sector 6197616
[  563.744669] Buffer I/O error on dev sda1, logical block 6195568, async page read
[  566.595427] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  566.595455] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  566.595467] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  566.595484] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 71 00 00 01 00
[  566.595497] blk_update_request: critical medium error, dev sda, sector 6197617
[  566.595512] Buffer I/O error on dev sda1, logical block 6195569, async page read
[  569.335588] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  569.335613] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  569.335625] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  569.335641] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 72 00 00 06 00
[  569.335654] blk_update_request: critical medium error, dev sda, sector 6197618
[  569.335668] Buffer I/O error on dev sda1, logical block 6195570, async page read
[  569.335684] Buffer I/O error on dev sda1, logical block 6195571, async page read
[  569.335695] Buffer I/O error on dev sda1, logical block 6195572, async page read
[  569.335705] Buffer I/O error on dev sda1, logical block 6195573, async page read
[  569.335718] Buffer I/O error on dev sda1, logical block 6195574, async page read
[  569.335729] Buffer I/O error on dev sda1, logical block 6195575, async page read
[  619.386592] usb 1-1.5: USB disconnect, device number 10
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: BryanC on August 13, 2015, 09:40:26 am
Hi all, The 2TB Seagate slim internal drive died tonight with medium errors. :(

I tried to recover with a few different tools in Linux and windows but shes gonski.

I did drop it when it was turned off a few weeks back and I'd been getting a few read errors.
It's been heavily used every day for several months now.

Code: [Select]
536.294955] usb-storage 1-1.5:1.0: USB Mass Storage device detected
[  536.295952] scsi host2: usb-storage 1-1.5:1.0
[  537.292227] scsi 2:0:0:0: Direct-Access     Seagate  BUP Slim SL      0302 PQ: 0 ANSI: 6
[  537.293784] sd 2:0:0:0: Attached scsi generic sg0 type 0
[  537.296403] sd 2:0:0:0: [sda] Spinning up disk...
[  538.301071] ..ready
[  539.311620] sd 2:0:0:0: [sda] 3907029167 512-byte logical blocks: (2.00 TB/1.81 TiB)
[  539.578285] sd 2:0:0:0: [sda] Write Protect is off
[  539.578309] sd 2:0:0:0: [sda] Mode Sense: 4f 00 00 00
[  539.578820] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[  539.637068] Alternate GPT is invalid, using primary GPT.
[  539.637144]  sda: sda1
[  539.639718] sd 2:0:0:0: [sda] Attached SCSI disk
[  543.300629] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  543.300655] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  543.300668] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  543.300684] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 90 a8 00 00 f0 00
[  543.300697] blk_update_request: critical medium error, dev sda, sector 6197416
[  546.162195] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  546.162236] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  546.162248] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  546.162262] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 70 00 00 01 00
[  546.162275] blk_update_request: critical medium error, dev sda, sector 6197616
[  546.162290] Buffer I/O error on dev sda1, logical block 6195568, async page read
[  549.334784] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  549.334819] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  549.334831] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  549.334848] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 71 00 00 01 00
[  549.334861] blk_update_request: critical medium error, dev sda, sector 6197617
[  549.334876] Buffer I/O error on dev sda1, logical block 6195569, async page read
[  552.207879] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  552.207917] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  552.207931] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  552.207946] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 72 00 00 06 00
[  552.207958] blk_update_request: critical medium error, dev sda, sector 6197618
[  552.207972] Buffer I/O error on dev sda1, logical block 6195570, async page read
[  552.207991] Buffer I/O error on dev sda1, logical block 6195571, async page read
[  552.208002] Buffer I/O error on dev sda1, logical block 6195572, async page read
[  552.208013] Buffer I/O error on dev sda1, logical block 6195573, async page read
[  552.208024] Buffer I/O error on dev sda1, logical block 6195574, async page read
[  552.208034] Buffer I/O error on dev sda1, logical block 6195575, async page read
[  555.147493] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  555.147530] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  555.147542] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  555.147558] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 70 00 00 01 00
[  555.147571] blk_update_request: critical medium error, dev sda, sector 6197616
[  555.147586] Buffer I/O error on dev sda1, logical block 6195568, async page read
[  557.920742] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  557.920781] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  557.920794] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  557.920809] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 71 00 00 01 00
[  557.920823] blk_update_request: critical medium error, dev sda, sector 6197617
[  557.920836] Buffer I/O error on dev sda1, logical block 6195569, async page read
[  560.915904] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  560.915944] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  560.915957] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  560.915973] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 72 00 00 06 00
[  560.915986] blk_update_request: critical medium error, dev sda, sector 6197618
[  560.916001] Buffer I/O error on dev sda1, logical block 6195570, async page read
[  560.916020] Buffer I/O error on dev sda1, logical block 6195571, async page read
[  560.916031] Buffer I/O error on dev sda1, logical block 6195572, async page read
[  560.916044] Buffer I/O error on dev sda1, logical block 6195573, async page read
[  560.916055] Buffer I/O error on dev sda1, logical block 6195574, async page read
[  560.916065] Buffer I/O error on dev sda1, logical block 6195575, async page read
[  563.744589] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  563.744616] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  563.744628] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  563.744644] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 70 00 00 01 00
[  563.744656] blk_update_request: critical medium error, dev sda, sector 6197616
[  563.744669] Buffer I/O error on dev sda1, logical block 6195568, async page read
[  566.595427] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  566.595455] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  566.595467] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  566.595484] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 71 00 00 01 00
[  566.595497] blk_update_request: critical medium error, dev sda, sector 6197617
[  566.595512] Buffer I/O error on dev sda1, logical block 6195569, async page read
[  569.335588] sd 2:0:0:0: [sda] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
[  569.335613] sd 2:0:0:0: [sda] Sense Key : 0x3 [current]
[  569.335625] sd 2:0:0:0: [sda] ASC=0x11 ASCQ=0x0
[  569.335641] sd 2:0:0:0: [sda] CDB: opcode=0x28 28 00 00 5e 91 72 00 00 06 00
[  569.335654] blk_update_request: critical medium error, dev sda, sector 6197618
[  569.335668] Buffer I/O error on dev sda1, logical block 6195570, async page read
[  569.335684] Buffer I/O error on dev sda1, logical block 6195571, async page read
[  569.335695] Buffer I/O error on dev sda1, logical block 6195572, async page read
[  569.335705] Buffer I/O error on dev sda1, logical block 6195573, async page read
[  569.335718] Buffer I/O error on dev sda1, logical block 6195574, async page read
[  569.335729] Buffer I/O error on dev sda1, logical block 6195575, async page read
[  619.386592] usb 1-1.5: USB disconnect, device number 10

You can use smartctl (from smartmontools) to identify the bad areas of your drive so that you can avoid them during repartitioning, if you're into that sort of thing. Considering it's just a workhorse drive that has (what I'm assuming to be) backed up data it might be worth it to save a few bucks. Unless you have your eye on this thing (http://www.amazon.com/Samsung-2-5-Inch-Internal-MZ-75E2T0B-AM/dp/B010QD6W9I), of course.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on August 13, 2015, 09:42:08 am
Yeah I already have a 1TB in my Id.

:)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: BryanC on August 13, 2015, 10:05:02 am
If you do go that route you might start looking at the Banana Pi or something similar. You can sync and stream via gigabit ethernet when wi-fi won't cut it and it has a sata bus so file i/o isn't dead slow like it is on the RPi. I'm using one in a file server right now and its exceeded my expectations. I don't know if the power draw is different than the RPi or not. I'm also assuming this has the nice side-effect of alleviating some of the filesystem corruption issues on power loss by using SATA vs USB.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: RoderickGI on August 13, 2015, 06:32:29 pm
Samsung make a 2TB SSD these days. May be more robust and damage resistant, though not cheap.

You know small devices are going to be dropped, repeatedly. If you ever commercialise this, users will forget there is a spinning hard disk in there and mistreat it as well.
Title: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on August 15, 2015, 09:29:50 am
I've nearly finished the revision to the prototype. I'll finish in the morning just before I go to the Sydney Audio meet.

New circuit board mount.

(https://farm1.staticflickr.com/729/20034074284_ef1c13cf13_b.jpg) (https://flic.kr/p/wwkSiS)20150815_104807305_iOS (https://flic.kr/p/wwkSiS) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

(https://farm6.staticflickr.com/5637/20646025532_e5599b6d7a_b.jpg) (https://flic.kr/p/xsqh6s)20150815_104824342_iOS (https://flic.kr/p/xsqh6s) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

(https://farm6.staticflickr.com/5693/20629193776_01c1d381b3_b.jpg) (https://flic.kr/p/xqW1AL)20150815_131658850_iOS (https://flic.kr/p/xqW1AL) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

I cut some tin sheet to make the internal mount.

(https://farm1.staticflickr.com/657/20655472095_51c9c79203_b.jpg) (https://flic.kr/p/xtfGee)20150815_105006407_iOS (https://flic.kr/p/xtfGee) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

It lives!  :o

(https://farm1.staticflickr.com/580/20655466625_e30cf41c98_b.jpg) (https://flic.kr/p/xtfEAV)20150815_130547014_iOS (https://flic.kr/p/xtfEAV) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

(https://farm1.staticflickr.com/774/20646275362_1fb04aaf74_b.jpg) (https://flic.kr/p/xsrymS)20150815_130555372_iOS (https://flic.kr/p/xsrymS) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

(https://farm1.staticflickr.com/781/20467463670_132e8f95ca_b.jpg) (https://flic.kr/p/xbD6SE)20150815_105024639_iOS (https://flic.kr/p/xbD6SE) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

(https://farm6.staticflickr.com/5799/20032893614_5ec2ebfdcd_b.jpg) (https://flic.kr/p/wwePku)20150815_133017822_iOS (https://flic.kr/p/wwePku) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

(https://farm6.staticflickr.com/5697/20468708809_343454f1fd_b.jpg) (https://flic.kr/p/xbKu1z)20150815_133028833_iOS (https://flic.kr/p/xbKu1z) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

(https://farm6.staticflickr.com/5655/20034505503_c2d1568b9f_b.jpg) (https://flic.kr/p/wwo5uF)20150815_133059852_iOS (https://flic.kr/p/wwo5uF) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: RoderickGI on August 15, 2015, 10:46:56 pm
The images are broken on your last post Hilton. Not displaying.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on August 16, 2015, 04:29:33 am
Not sure what was going on there. I redid the post and they seem to be fine now.

Here's the finished product.

I still have to do a sand and one more coat of paint. It was a quick rough coat friday night and I've already chipped the paint with the revisions I was making last night.

At the audio meet today I had 4 people ask to audition at their place on their system and two people wanted to part with cash to get one. :) (out of about 35 people and I didn't speak with everyone)

(https://farm1.staticflickr.com/688/20655358715_0722297831_b.jpg) (https://flic.kr/p/xtf7wp)IMG_5827 (https://flic.kr/p/xtf7wp) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

(https://farm1.staticflickr.com/782/20034432823_b269e3c03d_b.jpg) (https://flic.kr/p/wwnGTz)20150816_084917070_iOS (https://flic.kr/p/wwnGTz) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

(https://farm1.staticflickr.com/677/20467372488_485c7250a9_b.jpg) (https://flic.kr/p/xbCCLy)20150816_084935656_iOS (https://flic.kr/p/xbCCLy) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

(https://farm6.staticflickr.com/5729/20629107526_9e38167c03_b.jpg) (https://flic.kr/p/xqVyXG)20150816_084950010_iOS (https://flic.kr/p/xqVyXG) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr




A gratuitous shot of my Pi Brick flanked by FiiO E09k headphone amp and E17 DAC, Acer Iconia Tab 8 running JRemote and iPhone 6+ running JRemote and Klipsch Image One HeadPhones.  :)
One happy little digital family. ;)

(https://farm1.staticflickr.com/691/20467369368_ecd419fd46_b.jpg) (https://flic.kr/p/xbCBQL)IMG_5822 (https://flic.kr/p/xbCBQL) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: JimH on August 16, 2015, 04:37:28 am
Very cool.  Time to quit your day job.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on August 16, 2015, 05:56:22 am
Very cool.  Time to quit your day job.

I wish... Only 5000 more to sell and I can think about it. :)
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on August 17, 2015, 09:31:10 am
Images fixed.  I've moved over to flickr now.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on September 23, 2015, 10:23:31 pm
Just a small update. I did a battery test and got 6 hours battery life out of it before it shutdown. (that's with the 1TB SSD installed instead of the 2TB HDD)

It's been exceptionally stable since the last update to 21.0.7 so I'm staying on this version of MC for a while.

I'm designing the final printed circuit board for the switches, LEDS and wiring to tidy it up and make it plug and play with the Pi GPIO header.
That way if I end up mass producing it, I can just sell it as a case with switches and power circuit all mounted with the option for the charging circuit with battery.

People can then just plug in a Pi and optional HDD or SDD, load up an SD image and away they go. :)

That's the theory anyway.

PS. It doesn't get at all hot anymore with the SSD installed compared with the HDD.




Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: blgentry on September 24, 2015, 10:14:14 am
That's cool stuff.  Keep reporting your progress on this.  I wasn't all that interested at first, but the more you talk about it...  :) :)

Brian.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: gvanbrunt on September 24, 2015, 10:18:26 am
Not sure if you know about Ponoko  (https://www.ponoko.com/)or not. Good for prototyping cases etc.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: GuitRdone on October 15, 2015, 01:17:51 pm
Hi Hilton-

I've read through your whole Brick thread. Your device is wonderful! You are definitely a Wizard! I have a thread going on the hardware forum regarding replacing my iPod ( http://yabb.jriver.com/interact/index.php?topic=100602.0 ), and mwillem mentioned your Pi Brick thread. The Brick seems to be *almost* what I have been looking for.

Since I have so much digital content, my ideal rig would be a 3-5TB USB 3 drive, an MC renderer (which could certainly be the Brick), and my iFi Nano iDSD DAC. Actually, an X5 style player that incorporates a very nice DAC and headphone amp could eliminate the need for my external DAC.

What I didn't see in looking at the Brick is support for external USB devices. Again, storage is the most important for my needs. I would prefer that to a fixed internal storage capacity. Did I miss that in reading about the Brick? Do you plan on supporting that type of role for the Brick?

Are you close to marketing your Brick?

Thanks for your time!
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on October 15, 2015, 07:01:28 pm
Hi Hilton-

I've read through your whole Brick thread. Your device is wonderful! You are definitely a Wizard! I have a thread going on the hardware forum regarding replacing my iPod ( http://yabb.jriver.com/interact/index.php?topic=100602.0 ), and mwillem mentioned your Pi Brick thread. The Brick seems to be *almost* what I have been looking for.

Since I have so much digital content, my ideal rig would be a 3-5TB USB 3 drive, an MC renderer (which could certainly be the Brick), and my iFi Nano iDSD DAC. Actually, an X5 style player that incorporates a very nice DAC and headphone amp could eliminate the need for my external DAC.

What I didn't see in looking at the Brick is support for external USB devices. Again, storage is the most important for my needs. I would prefer that to a fixed internal storage capacity. Did I miss that in reading about the Brick? Do you plan on supporting that type of role for the Brick?

Are you close to marketing your Brick?

Thanks for your time!

Hi No problem!

I'm looking for a house to buy at the moment and busiest time of year for work so the project has been on hold. It's been working great in its current state, just not ready for mass production.
I'm learning designspark PCB software to design the circuit board and wiring to have a few prototypes made up but I haven't finished it yet.

The device has 4 usb ports.
1 is required for the wifi dongle leaving 3 free for DACs and HDD or 2 free USB ports if using an internal HDD.
If you use a Bluetooth dongle there's only 1 free for a DAC.


Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: GuitRdone on October 15, 2015, 07:53:54 pm
Thanks Hilton. I'll be interested in getting one when you are ready.
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on October 28, 2015, 12:08:48 am
Big news today boys!

I purchased a pair of Sony MDR-1ADAC active headphones.
http://www.sony.com.au/product/mdr-1adac

Built in DAC and amp.
DAC does up to 192/24 384/32 and also does DSD 2.8Mhz and 5.6Mhz on PC and yes even does DSD on the Pi2!!!
With the native iPhone lightning connector looks like it down samples to 44.1/48 16bit.
7 hours battery life.

The Pi2 can effortlessly push SACD ISO DSD and DSF files to the headphones built in DAC plugged directly into the USB port of the Pi2.
Best part, plug and play - no special setup.  :)
No more messy cables and external dacs/amps. ;D

AND best of all no more down conversion necessary, play every 2 channel file natively to the headphone DAC from the Pi2 usb port!  ;D ;D ;D
i.e. The DAC supports all the below with no down sampling playing back from the Pi2 via USB.

16, 24 and 32bit.

44.1k
48k
88.2k
96k
176.4k
192k
352.8k
edit: 384k  also
DSD64 2.8Mhz
DSD128 5.6Mhz

The Pi2 cant can decode and transcode DSD files to 352.8 PCM to the DAC in the headphones via USB without raising a sweat. (oops it is working hard but not skipping!)
This is DSD to PCM (just worked out how to get native DoP - first time with a DoP capable DAC)
(https://farm6.staticflickr.com/5780/21915099754_10a5d79e46_b.jpg) (https://flic.kr/p/zoyBDu)Pi2-DSD (https://flic.kr/p/zoyBDu) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

This is native DSD DoP 2.8Mhz using 3 cores for decoding.
(https://farm1.staticflickr.com/651/21915851354_6a00775eb6_b.jpg) (https://flic.kr/p/zoCt57)Pi2-DSD2 (https://flic.kr/p/zoCt57) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: RoderickGI on October 28, 2015, 12:40:27 am
Very nice.

If they were noise cancelling as well they would be almost perfect . . . except for the price. Although with all those features built in, they are probably well priced. :D
Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on October 28, 2015, 12:49:44 am
They also work on the Samsung Tab 3 8" I have. ;)
They do 192/24 on the tablet through JRemote. :)


When plugged into the iPhone, JRemote shows 192/24bit but the specs for the headphones say they are limited to 44.1 & 48/16bit on iPhone.

Maybe it's downsampling in the iPhone or maybe they mean with the native Apple Music player?
I know using my other DAC on the iPhone that the iPhone definitely supports 96/24 with JRemote.

The headphones PC cable also works through the iPhone camera connection kit. (showing 192/24bit in JRemote)

PS.. Giving them a good workout. Realllly nice sounding headphones, the built in headphone AMP has heaps of power and is clean and punchy and the bass from the drivers is full but not bloated, the mids are really present and the highs are very clear without being tedious and too bright. Great imaging, space and separation. These are easily my favourite headphones out of the Senn HD600 and Klipsch Image Ones. (the build quality is awesome too, lots of strong metal hinges, no fragile plastic on these bad boys.)  

In comparison the Image ones lack detail and have an exaggerated sloppy bass, and the HD600's lack the punch and power in the lower octaves and don't cut through as well at the top end.

Title: Re: Pi2 "Brick" JRiver Media Center - Battery powered 2TB portable MC20!
Post by: Hilton on October 28, 2015, 07:16:00 am
(https://farm6.staticflickr.com/5647/22529490122_3081290e18_b.jpg) (https://flic.kr/p/AjRwuS)Sony MDR-1ADAC on Pi2 (https://flic.kr/p/AjRwuS) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr
(https://farm1.staticflickr.com/589/21920271864_5813068617_b.jpg) (https://flic.kr/p/zp288N)Sony MDR-1ADAC on Pi2 (https://flic.kr/p/zp288N) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr

(https://farm1.staticflickr.com/772/22355307318_95d0b8b515_b.jpg) (https://flic.kr/p/A4sN25)Sony MDR-1ADAC on Pi2 (https://flic.kr/p/A4sN25) by Hilton (https://www.flickr.com/photos/133784514@N07/), on Flickr