On/Off Additional Switch for turn on / shutdown bananaNAS

Hello. I’m running a Banana PI m1 as a NAS to share digital content over my home. It’s still in test mode and it consists of bananapi, a 3tb wd red hdd, external power supply distinct for bpi and hdd, a lot of cables, network switch etc. To put some order I’m planning to put the NAS inside a 19" rack so I’ll need a dedicated case for it, that I’ll build. In this case I’ll put all the electronics and I’ll need a power button to turn on and to shutdown the system. I buyed a decent switch that you can see here:

Now I’m guessing on how to connect this switch to the bpi board to accomplish my goal of turning on / shutdown the system. Any advices on that?

can you share this button spec ,

Here’s some detail on size and circuit:

Specification: Latching type, push it—on, push it again — off Switch Rating: 6A/125VAC LED voltage: 12V Contact Configuration: 1NO1NC

Note that I’d like to use it to power/unpower the power supply (for both bananapi and hdd) but this way I cannot get a proper shutdown of the running system:

So what’s the correct approach?

OK ,i will let our R&D write and let you know how to use it .

Ok, I’ll wait! Thank you.

Desold power switch and sold your switch in place

:thinking:

My switch is a latching type while the one on board is a momentary one.

Latching is useful for my purpose of interrupt the power line upstream the power supply so that I have no power at all in the circuits when the switch is in OFF position. Anyway I need to shutdown the system prior to interrupt the power of the board…

You can connect your switch on gpio and write python code to shutdown system when switch clicked :slight_smile:

Can you be more specific on pins to use and code to execute? Even if I have a good background in electronics and solid bases on sw programming I’m totally new to these sbc boards!

Moreover, I’d like to cut off power at all when the button is switched off (and after a proper shutdown of the system!).

I can figure out these steps:

System is off. No power line reaches power supplies of bananapi and hdd, because of latching switch in OFF position.

Latching switch is turned ON then the power reaches both power supplies of bananapi and hdd and the system boots; this is the easy part!

Latching switch is turned OFF again: this can’t simply cut the power line of power supplies 'cause the system running on bananapi will be left in an inconsistent state and could bring disk errors/failures. So the need to a proper shutdown before to cut the power down!

try this? I got it to work on an M1+:

https://lowpowerlab.com/shop/ATXRaspi-R2

I used the same type of power button.

Something like this http://www.allaboutcircuits.com/projects/build-a-raspberry-pi-pushbutton-switch/ just modify RPi.GPIO to bpi library and modify print fonction to shutdown and make script run on startup on background its all

i have ask our R&D , the button for you choose ,can not control it by software, so just can use by this way:

if you want to On/Off by software with AXP chip .

just choose same like this Tact Switch on M1:

spec:

Seems a good solution… even if not the cheapest one! Will work on bananaPi? :no_mouth:

The button used in this example seems to be a non latching type… :neutral_face:

Ok, so simplest solution is the one suggested by sinovoip and soufyen first, that is “Desold power switch and sold your switch in place”! Not with my latching type switch, obviously, but using a momentary one as sinovoip stated.

I’ll try to find a momentary version of the button I own but this way I can’t cut power from power supplies that, instead, will be always feed even if not used by connected load.

The advice of kneiser, if applicable with bananapi, as I have seen on video is the most powerful/elegant solution because it allows to cut off completely the power from circuits and also is aesthetically fine because of led flashing during shutdown sequence. Anyway, I’m not sure this atxraspi is applicable with bananapi and tbh I’m even not sure of the button used in the video that really seems a momentary one. :thinking: I’ll try to ask some info to lowpowerlab people.

Many thanks guys for responses and advices… for now! :grin:

BPi M1 has AXP209 PMU, no need to buy external ‘smart’ power stuff.

Use a relay (or transistor/MOSFET) to switch on/off power to HDD when the board boots or shuts down (utilising any of the GPIO pins), connect 5V/GND to battery connector/pads (charger disables itself when 4.6V are exceeded), this way the (non latching) power button can be used to power on both board and HDD and also to do a clean shutdown with automatic unmount of HDD and cutting power afterwards. For the latter you might need

sudo apt-get install acpid

and a good OS image (kernel support)

Let me make sure I got your idea.

First I have to replace the latching type button with a momentary one and this isn’t a problem; next I need to connect this momentary button to the existing one on the board, in parallel (I think there’s non need to remove the original one).

Second, I need to use a battery as a support to power on the system? I didn’t know of battery connectors on the board :no_mouth: Where are located exactly? What kind of battery I need? I suppose lion or maybe lipo… but what voltage/capacity?

Third, I need to drive a relay (or equivalent electronic circuit) connected to a GPIO pin set by software so that when the system is turned on (thanks to the battery) and the code to setup the chosen pin is run, the relay switches and the power supply is feeded by the power grid; consequently the (always) connected battery is charged? And charge stops automatically when no more charge needed? This way, when I press again the button, the system shuts down safely and after there’s no more power on board the chosen GPIO pin value falls, the connected relay switches and consequently the power supply is disconnected from power grid.

The critical part for me is the GPIO related. I read I can drive external relays/devices but I’ve never done it. Any advice on which relay board is safely applicable for banana pi?

As I already said I’m totally new to this kind of boards but, if I have realized well your advice, this way I can solve my catch.

No battery involved. All Allwinner SoCs with PMU support have 3 power sources: DC-IN, USB OTG and battery. If you use DC-IN the power button has no function to power up. So you have to either use USB OTG (wrong since this is also just a Micro USB connection and Micro USB is CRAP to power devices reliably) or the battery connector. The latter is the only reliable connector to power some SinoVoip products at all.

Further reading:

http://forum.lemaker.org/forum.php?mod=viewthread&tid=8312&extra=page%3D1 http://linux-sunxi.org/Lamobo_R1#Powering_the_board