Can't get power button to work
#1
Hi,

Today I decided to add a power button to my Pine64. I have a momentary push button switch with a red LED that I got off eBay that I was going to use and I soldered some header wires to use the switch with the EXP connector pins (using pin 5). However, I cannot get the switch to work. It works as a reset switch (using pin 4), but not as a power switch. I also soldered on the included switch to the holes at the front of the board but that does work either. I tired using the System LED pin (pin 2) on the EXP connector for the LED on my button, but that is not working as well. I have the latest release of Ubuntu installed. I don't see what is wrong, the button I have works, but connected to the Pine64 it doesn't? Any ideas?
#2
(08-27-2016, 08:46 PM)AidenH Wrote: Hi,

Today I decided to add a power button to my Pine64. I have a momentary push button switch with a red LED that I got off eBay that I was going to use and I soldered some header wires to use the switch with the EXP connector pins (using pin 5). However, I cannot get the switch to work. It works as a reset switch (using pin 4), but not as a power switch. I also soldered on the included switch to the holes at the front of the board but that does work either. I tired using the System LED pin (pin 2) on the EXP connector for the LED on my button, but that is not working as well. I have the latest release of Ubuntu installed. I don't see what is wrong, the button I have works, but connected to the Pine64 it doesn't? Any ideas?

Hi Aiden

In a nutshell, from my understanding, the power button is of use for two main use cases 1) when you have the battery attached and 2) if you are using an android image. Rest of the time, it will simply confuse and not be of much help. To expand on use case 1, if you don't have the battery connected, the pine 64 will start up... and a few seconds later promptly shut down when it realises there is no battery to be found. With use case 2, the power button can be used to both power on the pine64 (with or without a battery), and also give access to the power off menu... otherwise powering the sucker off will be a bit tricky! Wink Thankfully, you don't have to worry about switch contact bouncing (which means the pine64 thinks the button is pressed multiple times) as the power management IC has built-in hardware denouncing, so you just give it a tap for a short press, and hold it for a second or two for a long one. 

There is a third instance you can use it, as if you have linux running, pressing the power button will trigger an event you can have code respond to, but I haven't bothered doing anything with that myself (other than to prove it can work). 

With the system LED, that probably doesn't do what you think it does. It's a user programmable LED, and can be controlled just like any of the other GPIO ports. Like xalius demonstrates here.  

Hope that clears that up for you. Yell out if you're still confused about anything... Wink
#3
(08-27-2016, 09:11 PM)pfeerick Wrote: There is a third instance you can use it, as if you have linux running, pressing the power button will trigger an event you can have code respond to, but I haven't bothered doing anything with that myself (other than to prove it can work). 

With the system LED, that probably doesn't do what you think it does. It's a user programmable LED, and can be controlled just like any of the other GPIO ports. Like xalius demonstrates here.  

I will also add, in addition to what pfeerick has said, that something some of us have discussed is that rather than soldering the system LED in place, it might be better to solder there instead regular male header pins, effectively giving you one more GPIO pin !  I use primarily gnu+linux, and I use the system LED as a final boot-up and system running normally indicator. If your PineA64 is running headless its best to put the indicator on the case front panel, and having a GPIO header pin to plug jumpers into is really helpful. I plan to post those codes as a sticky soon; they are still experimental for me.  

With debian the power button click is nasty! it puts the PineA64 board to sleep for which there is no recovery (well, except power removal );  however, if you HOLD the power button with debian running , then you will receive the debian normal 'shutdown dialogue'.  Its sweet, but, just remember to hold the power, don't just click it.

Edit:  Also, and this is important, on debian ( on mate desktop ) go into the Power Management Preferences and change the General Actions for the power and reset buttons !

System --> Preferences --> Power Management Preferences

Then click the General tab, and then set the power button to "Ask Me", and set the suspend button to "Do Nothing".

(hope that helps)
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
#4
(08-27-2016, 10:11 PM)MarkHaysHarris777 Wrote: With debian the power button click is nasty! it puts the PineA64 board to sleep for which there is no recovery (well, except power removal );  however, if you HOLD the power button with debian running , then you will receive the debian normal 'shutdown dialogue'.  Its sweet, but, just remember to hold the power, don't just click it.

Your debian comments are directed more when running as a GUI/desktop box, aren't they? As with a headless/console config, the power button will do zilch/nada/nothing if you press or tap it, unless you specifically add a monitor for it. And naturally, if you hold it for ~10 seconds, it will do a forced power off. 

I had thought about adding another female header to the pine next to the one for the IR receiver for the LEDs, but since the board doesn't use 2.54mm spacing for the LEDs (instead 2mm, center to center), a female header wouldn't fit, and a male one would need a bit too much bending for my liking. Thus plus the holes were a bit small for the thickness of bog standard 2.54mm spaced headers. I do have some of the round smaller pitch headers, but that would just have been a pain, as it would have been the only connector using it. Might as well just use the header pin on the EXP header... it's already there!

Hey Mark, did you mentioned something earlier about Android doing the same as the debian GUI... i.e. go to sleep with power off / hard reset being the only way to get the system responsive again? I had an earlier android build from a few months ago that I just booted up again, and it was being that way, but I could sort of get it to respond again when unplugging the mouse, and plugging it in just after hitting the power button to resume the pine64 from standby... 

And with the latest v5.1.1 8GB image, it seems to work perfectly... goes to sleep, wakes up, goes to sleep, wakes up. Having a power meter monitoring the pine when doing that sort of test is handy, as you can get a sense of if the pine has gone zombie, or is trying to respond, but just not getting all the way there. 

Sorry for the slightly OT post Aiden! Big Grin
#5
(08-27-2016, 10:58 PM)pfeerick Wrote: Your debian comments are directed more when running as a GUI/desktop box, aren't they? As with a headless/console config, the power button will do zilch/nada/nothing if you press or tap it, unless you specifically add a monitor for it. And naturally, if you hold it for ~10 seconds, it will do a forced power off. 
I had thought about adding another female header to the pine next to the one for the IR receiver for the LEDs, but since the board doesn't use 2.54mm spacing for the LEDs (instead 2mm, center to center), a female header wouldn't fit, and a male one would need a bit too much bending for my liking. Thus plus the holes were a bit small for the thickness of bog standard 2.54mm spaced headers. I do have some of the round smaller pitch headers, but that would just have been a pain, as it would have been the only connector using it. Might as well just use the header pin on the EXP header... it's already there!

Correct on all points ... yes, for headless operation you have to have some kind of monitor; I don't do that in the sense of the system monitor, however.

For my headless servers my power button triggers "my own" interrupt within a python button monitor.  In other words, instead of responding to the system interrupt I built a button monitor ( will post this next week ) that allows for a -SIGHUP as well as the button push. Again, I have a three second timer on it; which prevents accidental pressing. When I press and hold my headless machines' power button for three seconds the system enters into a normal 'shutdown -h now', so that I can power it off cleanly without having to sign in remote.

As for the holes, yes, they are slightly problematic due to size. For instance, if you were to solder an LED in the system led position, it fits better if you use a 3mm LED, rather than a 5mm standard LED. But, if you put the male header pin(s) in that position , there is a cool trick you can employ. You don't 'need' the header pin spacer!  all you really need are the pins. So, you pull the pins from their plastic spacer with a pair of needle nose pliers and then solder the pin in place 'without' the header spacer. I use individual female jumper wires, but you can use  a standard female jumper pair because the actual spacing is soooo close that even though its slightly tight it still works fine. The benefit to doing this rather than using the EXP header, is that it frees up the EXP header for other header plugs, like the cp2102 serial tty bridge from the pine store.  Anyway, its not for everybody, but it is an option which I have used.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
#6
(08-27-2016, 09:11 PM)pfeerick Wrote: Hi Aiden

In a nutshell, from my understanding, the power button is of use for two main use cases 1) when you have the battery attached and 2) if you are using an android image. Rest of the time, it will simply confuse and not be of much help. To expand on use case 1, if you don't have the battery connected, the pine 64 will start up... and a few seconds later promptly shut down when it realises there is no battery to be found. With use case 2, the power button can be used to both power on the pine64 (with or without a battery), and also give access to the power off menu... otherwise powering the sucker off will be a bit tricky! Wink Thankfully, you don't have to worry about switch contact bouncing (which means the pine64 thinks the button is pressed multiple times) as the power management IC has built-in hardware denouncing, so you just give it a tap for a short press, and hold it for a second or two for a long one. 

There is a third instance you can use it, as if you have linux running, pressing the power button will trigger an event you can have code respond to, but I haven't bothered doing anything with that myself (other than to prove it can work). 

With the system LED, that probably doesn't do what you think it does. It's a user programmable LED, and can be controlled just like any of the other GPIO ports. Like xalius demonstrates here.  

Hope that clears that up for you. Yell out if you're still confused about anything... Wink

(08-27-2016, 10:11 PM)MarkHaysHarris777 Wrote:
(08-27-2016, 09:11 PM)pfeerick Wrote: There is a third instance you can use it, as if you have linux running, pressing the power button will trigger an event you can have code respond to, but I haven't bothered doing anything with that myself (other than to prove it can work). 

With the system LED, that probably doesn't do what you think it does. It's a user programmable LED, and can be controlled just like any of the other GPIO ports. Like xalius demonstrates here.  

I will also add, in addition to what pfeerick has said, that something some of us have discussed is that rather than soldering the system LED in place, it might be better to solder there instead regular male header pins, effectively giving you one more GPIO pin !  I use primarily gnu+linux, and I use the system LED as a final boot-up and system running normally indicator. If your PineA64 is running headless its best to put the indicator on the case front panel, and having a GPIO header pin to plug jumpers into is really helpful. I plan to post those codes as a sticky soon; they are still experimental for me.  

With debian the power button click is nasty! it puts the PineA64 board to sleep for which there is no recovery (well, except power removal );  however, if you HOLD the power button with debian running , then you will receive the debian normal 'shutdown dialogue'.  Its sweet, but, just remember to hold the power, don't just click it.

Edit:  Also, and this is important, on debian ( on mate desktop ) go into the Power Management Preferences and change the General Actions for the power and reset buttons !

System --> Preferences --> Power Management Preferences

Then click the General tab, and then set the power button to "Ask Me", and set the suspend button to "Do Nothing".

(hope that helps)


Thanks for the info guys, that clears it all up. I thought I damaged the power traces or something with my terrible soldering  Big Grin
I guess i'll take a look at triggering an event in linux and see what I can do with that and I'll go back to my original method of using the GPIO for the button LED. 

(08-27-2016, 10:58 PM)pfeerick Wrote: Sorry for the slightly OT post Aiden! Big Grin

No worries, it's interesting infomation to read anyway
#7
(08-27-2016, 11:22 PM)MarkHaysHarris777 Wrote: Correct on all points ... yes, for headless operation you have to have some kind of monitor; I don't do that in the sense of the system monitor, however.

For my headless servers my power button triggers "my own" interrupt within a python button monitor.  In other words, instead of responding to the system interrupt I built a button monitor ( will post this next week ) that allows for a -SIGHUP as well as the button push.

Yes, perhaps an unfortunate choice of words... interrupt is the more proper word to have used, but then that would require explaining it to ensure it's meaning was clear! But it gets the point across still... als long as you don't confuse it with a display monitor! xD

Glad to hear you've got something in progress... I was going to adapt a nice blink/power service someone made for the Chip, but if you have something working already, that'll be the way to go.

I don't use the pine64 serial adapter, so good point for anyone who does. The pins I had still wouldn't have fit as they were too big for the holes, but a minor re-drilling is all they would have needed as they were so close to fitting.

Did you see my second post above re: android? Was it you commenting about the power button and android freezing... or was I confusing with another post about debian?
#8
(08-28-2016, 01:25 AM)MarkHaysHarris777 Wrote: It was someone else... but its true !

... with Android if you click the power button, instead of holding it, she will suspend with no recovery except removing the power or pressing the reset button/  its been a fit for me with my playbox; because I have trouble avoiding contact bounce due to reaching into the enclosure ( through a trap door ) and not being able to reliably 'hold' the button.  I have to redesign that whole thing...  rats.

Hm... it might be worth you trying again with the latest Android image then - I was unable to reproduce that with the 8GB "Android 5.1.1 Image (HDMI Video Output) Release 20160711"... I could consistently put the pine64 into standby by pressing the power button, waiting about 10 seconds for the power usage to settle, and the pressing the button again to wake it up. This is with the direct-mount PCB mount tactile switch. The earlier image was erratic... and would consume the right amount of power to indicate it was awake again, but no output on the HDMI. I suppose another possibility might be the difference between HDMI and LCD... because you'd probably want to use the LCD build since you have the LCD... Most I've had to do with the latest build is switch my display back to HDMI as it auto-switches back to the computer when the pine64 goes to sleep.
#9
thanks for the note... I'll definitely try it... yeah, both of my Android images ( hdmi and LCD ) are not the latest ( well, if it aint broke don't fix it )...   or, if it ain't broke, fix it until it is !

Thanks
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
#10
Just an update - I tried to test the input of the power button using evtest in Ubuntu and nothing is showing up when I push the button - not for the button soldered to the connection points at the front or for the button connect to the EXP connector. Should this be working in Ubuntu or am I doing something wrong? I think I'm going to try and Andriod image to see if the power button is actually work properly.


Possibly Related Threads…
Thread Author Replies Views Last Post
Question +LTS/SOPINE USB voltage on power off using LiPo battery GregH 0 951 05-06-2020, 11:23 PM
Last Post: GregH
  Battery case and power question Twistedx 2 2,197 12-24-2018, 08:04 PM
Last Post: Twistedx
  Power Cord & SD Card Maximum 1 1,306 01-09-2017, 04:41 PM
Last Post: Ghost
  Board will not boot/does not work major7 2 2,006 09-03-2016, 02:53 AM
Last Post: major7
  Wires as power button Nittola 5 3,085 08-19-2016, 03:35 PM
Last Post: MarkHaysHarris777
  Push button on/off switch Wolfenstein 6 3,688 08-01-2016, 11:05 AM
Last Post: MarkHaysHarris777
  Day lost in getting it work ptiwari 4 2,353 07-24-2016, 01:17 PM
Last Post: ptiwari
  Power Jumper rahlquist 12 7,678 04-03-2016, 09:29 AM
Last Post: SkimMilk

Forum Jump:


Users browsing this thread: 1 Guest(s)