Hypnic Power Manager for Raspberry Pi (and other SBCs)

The Hypnic Power Manager
973VivV.jpg


Features
  • Switch power on/off to SBC
  • Provide power switch for SBC
  • Provide power status with LED
  • Remove battery maintenance (use supercapacitors)
  • Provide enough energy to allow the SBC to power down gracefully
  • Optionally, power on SBC when external power is turned on
  • Optionally, power on SBC only where there's enough charge

The Hypnic Power Manager does all of this in a tiny footprint. It's designed to be used with any 5V external power supply of your own choice - a simple wall wort or even an AliExpress special will do, it's not fussy - as long as it's 5V.

When the power button is pressed, or after the external power supply is removed, the board uses supercapacitors to power the SBC - this power supply will last approximately 30s depending on power draw from the SBC. However, the Hypnic sends a "shutdown" signal to the SBC by pulling a pin low on the SBC. A script on the SBC detects the pin state change and shuts down the SBC. Once the graceful power down is complete, a script to pull a pin on the SBC high pulls a pin high on the Hypnic and it removes the power supply to the SBC.

It's powered by an ATTiny24/44/84 and the code is written in Arduino (as that's easier for most DIYers) / Python for the SBC elements - all code is open source, so you can modify and reflash the controller, although you will need an ICSP programmer. The schematic, PCB layout and code are all completely open source.

Why isn't this a Pi HAT?
Screw terminals for all connections to the SBC - this is an intentional choice to make it work with all SBCs - not all SBCs have the same layout as the Raspberry Pi - if this was "Raspberry Pi shaped" (i.e., a HAT) it will only really work with the Pi. Sure, you'll need to hook it up with a few wires, but now it'll work with any SBC and you don't have to mount it on top.

Why did you make this?
While building a new digital audio player based on a Raspberry Pi (a story for another day) I wanted to turn the Raspberry Pi into an "appliance". Like most Single Board Computers (SBCs), the Raspberry Pi by itself doesn't (really) feature a power button without abusing the GPIO. On top of that, you can't simply remove power from it in since it's very possible that you'll either suffer data loss or, worse, corruption. I needed a way to gracefully power down when power is removed. I couldn't find a solution to this off the shelf that wasn't a battery-based UPS. This doesn't work for my application since I'm not trying to keep the Pi running, I want to power it off!

To be clear, yes, I know you can short GPIO pins to power on the Pi, and you can use scripts to with GPIO pins to power it off again. I also know there are UI options - but they're not always practical. And none of these protect against power loss and brownouts, which is something else I need to do.

There are many "UPS" solutions, but they're intended to keep the device on for as long as possible and most don't have a nice way of powering it back on again and virtually none support a power button. On top, they all require batteries and battery maintenance, which is a pain. The answer, of course, is to build it yourself. Enter the Hypnic Power Manager.

Hypnic?
In case you're wondering about the name, a Hypnic Jerk is that sudden movement you get just before you go to sleep... I thought that was apt for a device designed to provide enough power to let the SBC "sleep" and power it down!

PVryRP7.jpg

1GAmucO.jpg

4tknKki.jpg

RVWs2sj.jpg


More Information / Documentation
falk/hypnic at main * gilphilbert/falk * GitHub

Code for the ATTiny
GitHub - gilphilbert/hypnic
This is ready to be opened in VSCode

OK, OK, I want one!
The Hypnic Power Manager is $20 including P+P to mainland USA. Shipping to elsewhere will add some shipping cost. Just PM me with your order!
 
Last edited:
On my Picoreplayer installation there is a shutdown menu item.
It enters a Halt state which consumes little power and You can safely remove the PSU.
With the PSU always connected, I then just switch / short pins 5&6 to boot.
You could perhaps implement an automatic battery takeover solution for making it more portable.
 
Ah, yes, thanks - a good point. I missed that in my intro... while many distros have shutdown menu items and options, that's not very "appliancey", needing to know you can't just cut the power. My system will only be powered on when it's needed, not all the time. I also considered something like Alpine Linux as well, but that introduces more software complexity.

I'm using, amongst other things, a Rotel RLC line conditioner which has a feature that controls power on/off sequences to prevent "pops" when the devices are turned on and off. It doesn't send triggers, it just hard switches off the devices. It's a handy feature, but I don't want to be logging into a web UI every time I power off my hifi.

My system is built into a full hifi chassis (I'll create a thread for the build later) and I really wanted it to operate like a hardware appliance, so if my kids (or wife) turns off the whole stack it won't kill the Pi.
 
Actually, there is an inexpensive off the shelf solution that fits most of your needs. It lacks the UPS features of your project but adds some others, including powering the Pi from a battery.

It's called the Witty Pi: Witty Pi 3 rev2

Features:

  • Power your Raspberry Pi with higher voltage (up to DC 28V).
  • Gracefully turn on/off Raspberry Pi with single tap on the button.
  • Fully cut the power of Raspberry Pi and all its USB peripherals after the shutdown.
  • Automatically synchronise time between realtime clock and Raspberry Pi.
  • Monitor the temperature around your Pi (thanks to the sensor in RTC chip).
  • Schedule the startup/shutdown of your Raspberry Pi.
  • Write a script to define complex ON/OFF sequence.
  • Shutdown Raspberry Pi when input voltage is lower than the threshold value.
  • Turn on Raspberry Pi when input voltage raise over the threshold value.
  • Long hold the button to force power cut (when the OS loses response).

User manual is found here:
http://www.uugear.com/doc/WittyPi3Rev2_UserManual.pdf

Quick Review:
New Witty Pi 3 from @UUGear gives you a realtime clock and lets you power your Raspberry Pi from a battery - Raspberry Pi Pod and micro:bit base
 
Thanks Charlie, I hadn't found that one in my searches, but it wouldn't fit my needs anyway, which is a shame - like many, it comes very close.

This model uses batteries for a UPS function. That's not the goal I have; since audio appliances don't need to run on batteries (why would they, the amps would be off!) this means the appliance will be very regularly powered on/off and the Pi will only run on battery for around 10s before being powered off. Not only are batteries overkill, but the battery life is likely to be very quickly affected. For reference, I've run an idle Raspberry Pi 3 with a USB WiFi adapter for 30 minutes on a tiny 400mAh battery. Another goal was to build something that has no battery maintenance (hence my use of supercapacitors).

It also uses the Raspberry Pi HAT layout. While that's not problematic for many, I wanted something that will work with any SBC, not just the Raspberry Pi. This is for a number of reasons, not limited to the fact that my stack is physically very high already (I'm using iancanada's hardware which stacks pretty high) and another HAT would stop the stack from fitting into my 2U case, but also because I wanted to support non-Raspberry Pi SBC, not just the Pi. It's likely that I'll switch to a Jetson Nano soon for my build and it uses a totally different GPIO layout and a Pi HAT won't work.

I don't have the long-press feature though, that would be nice to add so I'll put that into my firmware. The scripting stuff can be easily added too, it's just bash scripting for the Witty Pi (although I'm using Python).

Thanks!
Phill
 
Progress

So a little progress update. My SMT boards arrived and I've been working through them. They look fantastic, but I've found a couple of errors. One small and one... not so small.

USbAVCD.jpg

The SMT "prototype" minus the supercapacitors

The small issue is that the labels for the "SAFE" and "HALT" pins are backwards - no disaster, but not ideal. The bigger issue is that the gate for the MOSFET features a pull-up pin, which comes from the diode that protects the ATTiny. While that diode is a shottky diode and has a fairly low forward voltage drop... it's still too large and the MOSFET never turns off. The voltage difference is 0.6V but it's enough to turn on the MOSFET which has a VGS(th) of just 0.4V. The result is that the single board computer never gets powered off!

A little hand-soldering of tiny SMT resistors and scratching out the trace fixed it, but it's not pretty (and definitely not reliable). For a test bed though, it's fine.

C7Z3jRR.jpg

The SMT "prototype" (no supercaps) with the 5V linear power supply fitted

I've updated the board and ordered some replacements with the issues addressed. They're most of the way through production and the firmware is now pretty much done, so now I'm just waiting for the boards to arrive so I can get the finished product in place.
 
I am very new to Rpi. However, after some careful research, I bought a Raspberrypi 4 8GB and a Argonone V2 case. Power is from an Allo Shanti Linear Supply which has two outputs: 5V 3A and 5V 1A2. So this also powers my DAC, a Topping DS50s. Ground the Shanti power supply to the entire audio chain at one point. Tried Moode and didn't like it. I tried picore player 64bit and couldn't go more than half way through as I couldn't find local libraries. An External HDD is connected to one of the USB3.0 ports of the pi. DAC is connected to one of the USB2.0 ports of the pi. Have a shielded Ethernet cable from Router to pi.

Other equipment consists of a Marantz CD 5004 player. Coax connection to DAC. Diy clone of First Watt M2 amplifier and Fostex FE168ESigmas in MLTQWTs.

Finally used Volumio2 and the Argonone scripts for Power Button and Fan Control. I , changed the Fan settings to custom - 40degC/20%, 45degC/30%, 50degC/50%, 55degC/75% and 60degC/100%.

I use BubbleuPnP to play YouTube Video in Volumio as renderer or local music from Hard Disk. If you have a premium Spotify account, Volumio has Spotify Connect. And ofcourse, Web Radio built into Volumio.

Smart phone or Laptop is used as a Remote Control for the Raspberry Pi4.

System sounds better than I have had anything before.

What is relevant to this post is that Raspberry Pi4 can be fully shut down (1) Using browser with Volumio IP, (2) Using Volumio App or (3) Holding down the Power Button on the Argonone V2 case.

Power up for the Raspberry Pi is just a momentary press of the same Power Button on the Argonone V2 case.

No fear of SD card corrupting.
 
Last edited:
That looks like a nice case and I'm glad it's doing what you need! I'm aware of VolumIO - I've both used it on many devices and I've contributed code to the project - it's a great bit of software that's very versatile.

Yes, you can use a power button or UI options, but that really means the device is a PC, not an "appliance" (which is what I'm trying to build). For example, the user needs to know that it's a PC and they can't just yank the power. VolumIO is great for DIY'ers, but I really wanted something that felt more like a hifi device than a PC. It also doesn't protect the device against total power failure / brownouts - I've experienced everything from a library emptying itself through to complete card corruption due to this.

You can read more about my build here: FALK DP-01. This is currently paired with two Rotel monoblocks, my own custom-built PA-01 modular passive preamplifier and a pair of Kef R11s.
 
Hi.

Could you please post a picture that shows how this module connects to the RPI.


The WittyPi thing posted by Charlie leaves the GPIO header 100% accessible...
...which is very much appreciated by many users.


While we're at it. What about case?

What case - nope - actually what "cases" (module and Pi) are you suggesting?



THX
 
Last edited:
Great questions - I'm working on some detailed documentation that should answer some of this.

Connections to the SBC are very simple:
  • +5V (pin 1 or 2 on the header)
  • GND (any available GND pin on the header)
  • HALT (any GPIO on the header)
  • SAFE (any GPIO on the header)

Since this is designed to work with any SBC (not just the Raspberry Pi) it's not "HAT shaped"; it's true that this makes it hard to stack (or it would have to be connected to the top of the stack). It's also worth bearing in mind that the supercaps are pretty big (height) so the stack would be quite tall. That said, creating a "companion" HAT would be trivial; this would allow stacking and allow connectivity to the complete header - it also shouldn't be very expensive, perhaps $6-7.
Edit It's worth pointing out that you'll lose flexibility here - I would have to select two pins for use as the HALT and SAFE connections (as the WittyPi does) which then wouldn't be available for other uses.

As for cases, this is unlikely to fit in any off-the-shelf raspberry pi cases since it's not HAT shaped. I really designed this for use in custom cases - like HiFi cases, etc. I actually created it for use in my PA-01 project where it's working perfectly. I also use one inside a POE Ethernet switch that also hosts a NanoPi Neo that serves as a PBX-in-a-box.
 
I now see where you're coming from.

Personally I don't like audio devices like your DP-1. Why? Displays, IR controls asf I consider ancient relics from the dark times. These add high complexity and cost and long hours @ no value-add.

IMO SBCs (and modern audio chains) gotta run headless and the control is to be done 100% via app or browser. I mean it's 2021.

Anyhow. Kudos to such a nice DIY build. I am pretty sure a lot of hours went into the project.

...Headless and remote control. Another topic.

That's another issue I have with your solution. Since a couple of years I am running my own RPI Wifi power switch based on a wireless esp8266 module running Tasmota and a relay. I am actually using a couple of relays and esps to handle my entire audio chain.
This way you can easily turn on/off all at once (with delay if needed) and integrate all the stuff into your home automation projects. >> All family members in the house just have to push a single icon on the phone and the entire audio system starts properly up.

Perhaps you give the wireless approach a thought.


Anyhow.

I think it'd be a good idea to develop a RPI module that won't occupy the GPIO header or limits access to any other feature. Trying to remain SBC generic limits your options.
Keep in mind. The audio relevant SBC world is driven by RPI nowadays. Most other SBCs IMO became pretty much irrelevant. Even if some SBC HW betters the RPI, most of
these manufacturers fail on the SW/firmware part in comparison.



Anyhow. Thx for sharing your project and ideas.
 
Last edited:
Disabled Account
Joined 2002
That is just a personal opinion. In reality many users prefer the display. In reviews of commercial gear the lack of a display is almost always noted as a drawback. Many also prefer local storage but this is very rare in ready built devices as the streaming hype goes on. IMO it is very good to make the device for general use with any SBC as RPI can and will be bettered by a new SBC that is designed for audio.

Using wireless on the contrary....
 
Last edited:
  • Like
Reactions: 1 user
That is just a personal opinion. In reality many users prefer the display. In reviews of commercial gear the lack of a display is almost always noted as a drawback. Many also prefer local storage but this is very rare in ready built devices as the streaming hype goes on. IMO it is very good to make the device for general use with any SBC as RPI can and will be bettered by a new SBC that is designed for audio.

Using wireless on the contrary....

Nope. I don't see any SBC that comes close to the RPI any time soon. It's HW AND SW that matters. And market share.
RPI SW and community + 3PP support is so much ahead of anything else out there. There's no chance that any company is able to catch up soon.

Anyhow. gilphilbert could offer a RPI specific gpio adapter which wouldn't block basic SBC functionality. That'd be a generic SBC issue affecting all SBCs anyhow. If he starts with RPI he covers most of the market. :D

****

Yep. Great. Looking at tiny low-res low-q displays from a 12-15ft distance. Makes sense. :rolleyes:
OR. Once in a lifetime using a flimsy display for basic setup! That's what I call highly efficient. :p

As far as I recall most reviewers of devices or features like these displays where looking for the switch how to dim or turn off these IMO mostly useless displays. ;)

Fact is. This is old school technology. For old-school folks. And all this is kept alive to have at least some differentiation in place.
As I said. All this just means higher complexity, more distortions, more complex power supplies, more cost, you name it.

The other reason for pretty much useless displays and weird multifunction buttons. Lack of competence.
Lack of competence to write proper drivers that offers access to the devices through the drivers and web/app.
I find it embarrassing and ridiculous that e.g. companies like Topping, or Gustard or SMSL, still offer flimsy displays and IR controls and stupid buttons on the front. And no access to volume control filters and settings through a driver.
Kudos to Allo which offers access to their DACs via driver. Though somehow they also got involved in the flimsy display business recently (Revolution/Boss2). :rolleyes:


And yes. That's my opinion after more then a decade working in that area. ;)
 
Disabled Account
Joined 2002
This is what I thought of youth.. I expected watches to be extinct soon as anyone seems to have a smart phone that indicates time perfectly... and what do I see? They buy analog watches.

I tested it out of curiousity. A few were persuaded to try out a headless streamer and an old Sony HAP-S1 that has knobs, IR and an app. They really liked the knobs :D

Considering NAD M10, Cocktail Audio and HiFi Rose devices going the display, knobs/touchscreen way I guess there are enough customers that prefer that. It also seems all in one devices are the future.
 
Last edited:
Raspberry Pi Companion Board

Talking about the companion board:

VxQCpOP.jpg


I put this together quickly. It's not ready (the pins are 2mm out of place) but it's fine to show what it would be like. It leaves all the IO pins completely free for use and allows stacking. All this really does is breakout the 5V rail and pins 11 and 13 (BCM GPIO 17 and 27) for the Hypnic to use. I could make this "configurable" on the board, so you could choose from two pin options. As some HATs have pins hardwired this would allow some flexibility.

Here it is below connected to a Hypnic board with a spare HiFiBerry DAC+ I have laying around:

pknuK08.jpg


If there's interest, I can order some PCBs for anyone who wants to order one. They'll come fully assembled, like the Hypnic itself.