1

I want to create a stand-alone internet radio device. Therefore I want to use an existing subwoofer box with connected speakers. Inside the subwoofer box there is the electronics for the sound system. There is also a 5V supply wire where I can connect my Raspberry to.

But what if my radio is running and I don't want to listen to it anymore? I can't just plug out the subwoofer box from the socket. This will cause the Raspberry Pi to lose its supply. The filesystem on the SD card will be harmed if such a plug-out is performed when OS is running. I'd like to properly shut it down by recognizing the plug-out and executing sudo halt after that.

What is the best solution for my intention? I have thought of a backup battery for the Raspberry Pi. Just like the battery which is used on motherboards. But will 3.3V be enough? Is there a battery which can provide that much current to run the Raspberry Pi (Note: a HD44780 display and a WLAN dongle is also connected to the Raspberry Pi)? How can I assure the battery is not used when the regular 5V supply is available (to not use battery AND 5V supply at same time).

Any help is appreciated.

W5VO
  • 18,303
  • 7
  • 63
  • 94
arminb
  • 1,622
  • 4
  • 21
  • 34
  • There are lots of GPIO pins. You can attach a button to it and run a program/script to check for it's state periodically or let for interrupt, which would run `halt` for you. – TNW Apr 18 '13 at 18:15
  • I'd like my system to be able to get plugged out at any time. A turn-off button is no option for me because I will have to wait till the system is down. – arminb Apr 18 '13 at 18:17
  • You'll always have to wait, all the writes have to be stopped. Quickest thing is to sync and remount SD as read only on a button press, then take out the plug, which almost as fast as just plugging it out, but I can't assure you it's 100% safe. – TNW Apr 18 '13 at 18:20
  • No, with a backup circuit for example I, the user, wouldn't have to wait. I just plug it out and put it back to its place. Meanwhile the system is getting shut down properly. – arminb Apr 18 '13 at 18:23
  • Essentially, you want to create a limited `UPS` situation. And it so happens that the Raspberry PI BETA Stack Exchange has this answered: http://raspberrypi.stackexchange.com/questions/1360/how-do-i-build-a-ups-like-battery-backup-system – Passerby Apr 18 '13 at 18:36
  • 3
    You could figure out how to run the Pi with all of the filesystems mounted read-only. Then you should have no problems with corrupted filesystems by turning it off. – Craig Apr 18 '13 at 19:53
  • You don't necessarily need the filesystems even mounted read-only. There are plenty of filesystems out there which can journal data as well as metadata, including ext4 when mounted with data=journal. Such a filesystem is robust against power failures in all cases. – Phil Frost Apr 18 '13 at 20:39
  • 1
    @PhilFrost Isn't Journaling on SD cards pretty much a no-no? Constantly writing to the sd card will kill it quickly. Same with ATime. It's normally recommended to disable journaling and use the noatime mount flag. – Passerby Apr 18 '13 at 20:42
  • 1
    @Passerby depends on how much writing you do, how your SD card and software perform wear leveling, whether you are using SLC or MLC flash, what your allowable failure rate is, and so on. Sure it's a failure mode to consider, but I wouldn't say it's a "no-no". – Phil Frost Apr 18 '13 at 20:47
  • When you say "plug out" is that from a Mains socket (AC Power)? Is the 5V a regulated power supply coming from the Mains or from a battery? Designing a backup shutdown circuit is not difficult, but I think a bit more clarification would be helpful. – Kurt E. Clothier Apr 18 '13 at 20:50
  • It's a plug out from a main socket. 5V are coming from a regulator. – arminb Apr 18 '13 at 20:51
  • Follow up question: do you need to always unplug it from the socket, or would a power switch be acceptable? Unplugging things while they are drawing much power is usually a bad idea anyway due to the possible arcing. – Kurt E. Clothier Apr 18 '13 at 21:00
  • A power switch would be also accepted. – arminb Apr 18 '13 at 21:11
  • @PhilFrost in an average consumer use computer, with non-fixed software usage and without a specific brand/model sd card? It's the biggest failure mode short of physical damage. – Passerby Apr 18 '13 at 21:17
  • http://electronics.stackexchange.com/questions/61877/shutdown-controller-for-raspberry-pi-in-a-car is a very similar question. – Scott Seidman Apr 18 '13 at 21:21
  • 1
    @Passerby and the biggest failure mode of resistors is overheating. Does that mean they all need to be liquid cooled? No, you look at the power dissipation of the resistor and size it appropriately. If you are using flash storage, you look at how much writing you do, and the acceptable lifetime, and make appropriate decisions. – Phil Frost Apr 18 '13 at 21:46
  • @PhilFrost and how does a consumer user of any average computer system do that? – Passerby Apr 18 '13 at 22:55

0 Answers0