cecul
Posts: 5
Joined: Tue Nov 03, 2020 1:24 pm

Re: Power on / off button for Pi

Tue Nov 03, 2020 6:03 pm

I was using Windows based car pc for 6 years. https://acurazine.com/forums/1g-tsx-per ... ll-909649/

But it's time to switch Raspberry Pi
I will use Rpi 4B in my car to NAV, music, etc...

I read the topic. I'm so sorry for ugly simple diagram :lol:
As i understand, this diagram will work. I added some text in the picture and tried to explain.
So...
Rpi will get power constant by 12V. to 5V DC converter.
Relay or some pcb gets contant and ACC 12V. Output contacts wired to GPIO 3 and GPIO 17. When i turn on the ignition key, relay will trigger two contacts will close (short circuit) that wired to Rpi. It must stay only 1-2 seconds as closed and must release them. And will do nothing untill igniton key turn off. Then relay will do same thing. Close, stay 2 seconds and release the contacts.

Also i want to add a momentery button for manual operations.

Am i right guys? Do you think it will work? I will be appreciated to alternative ideas.
Image
Attachments
RaspOnOff2.jpg
RaspOnOff2.jpg (119.74 KiB) Viewed 1041 times

User avatar
thagrol
Posts: 4978
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Power on / off button for Pi

Wed Nov 04, 2020 12:15 pm

Several comments on that:
  • Are you going to be using I2C? If not you only need to use GPIO 3.
  • Your momentary button needs to connect between the GPIO(s) and ground not just between the two GPIO.
  • I don't think your relay usage is correct:
    • A single relay doesn't work the way you think it does. Apply power and the internal contacts change position, remove it and they change back.
    • You almost certainly don't want to feed battery power into the relay. Just ACC and vehicle ground to the coil. GPIO(s) and the Pi's ground to the switch terminals.
  • On most vehicles ACC power is cut when you start the engine. This will cause a reboot.
  • A shutdown Pi still draws a small amount of current. This will drain your battery over time.
For my own in car Pi I went the simplest route: read only file system and powered from the ACC feed via a suitable buck converter.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
Imperf3kt
Posts: 4468
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia
Contact: Twitter

Re: Power on / off button for Pi

Wed Nov 04, 2020 8:00 pm

thagrol wrote:
Wed Nov 04, 2020 12:15 pm
  • .
  • A shutdown Pi still draws a small amount of current. This will drain your battery over time.
Maybe not. A shut down Pi4b uses 0.069A according to https://raspi.tv/2019/how-much-power-do ... 069%20Amps.

My car has a security system, and a few LEDs that stay powered constantly. My battery is going on seven years old and still kicking. I'm sure 7mA won't harm.
55:55:44:44:4C
52:4C:52:42:41

Rose tinted glasses are difficult to see through.

User avatar
rpdom
Posts: 18709
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Power on / off button for Pi

Wed Nov 04, 2020 8:31 pm

Imperf3kt wrote:
Wed Nov 04, 2020 8:00 pm
thagrol wrote:
Wed Nov 04, 2020 12:15 pm
  • .
  • A shutdown Pi still draws a small amount of current. This will drain your battery over time.
Maybe not. A shut down Pi4b uses 0.069A according to https://raspi.tv/2019/how-much-power-do ... 069%20Amps.

My car has a security system, and a few LEDs that stay powered constantly. My battery is going on seven years old and still kicking. I'm sure 7mA won't harm.
0.069A (rounded up) is 70mA, not 7mA. My car battery is older than that and doesn't hold a charge well between my few short journeys. I'd rather not drain it any faster than it is already.
Unreadable squiggle

cecul
Posts: 5
Joined: Tue Nov 03, 2020 1:24 pm

Re: Power on / off button for Pi

Wed Nov 04, 2020 10:10 pm

Thanks for replies.
thagrol wrote:
Wed Nov 04, 2020 12:15 pm
Are you going to be using I2C? If not you only need to use GPIO 3.
I won't use I2C. So I will use only GPIO 3.
thagrol wrote:
Wed Nov 04, 2020 12:15 pm
A shutdown Pi still draws a small amount of current. This will drain your battery over time.
I think it won't be a big problem. I use my car daily to go to work around 50 km per day and it takes more than 2 hours. If i need to disconnect it from car battery after shutdown, it will get any problem? File system, sd card corruption etc?

I have an ATX power supply for car usage. I was using it in my previous PC based carputer.
It has constant 12 V and ACC inputs. It feeds pc via standart ATX power socket. Also 2 wires connected to power button pins on the mainbord.
It waits 10 sec. when ignition key turn on and makes startup via connected power button pins on the mainbord.
It waits 45 sec. when ignition key turn off and makes shut down via connected power button pins on the mainbord.
I think that it will be ok for Rpi too. I only need connect it's two wires to GPIO 3 and ground.


I think this method will work. What do you think?
Attachments
psu.jpg
psu.jpg (69.05 KiB) Viewed 975 times

User avatar
thagrol
Posts: 4978
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Power on / off button for Pi

Thu Nov 05, 2020 10:02 am

cecul wrote:
Wed Nov 04, 2020 10:10 pm
I think it won't be a big problem. I use my car daily to go to work around 50 km per day and it takes more than 2 hours. If i need to disconnect it from car battery after shutdown, it will get any problem? File system, sd card corruption etc?
If you do a proper shutdown there shouldn't be any problems. If you don't, expect some.
I have an ATX power supply for car usage. I was using it in my previous PC based carputer.
It has constant 12 V and ACC inputs. It feeds pc via standart ATX power socket. Also 2 wires connected to power button pins on the mainbord.
It waits 10 sec. when ignition key turn on and makes startup via connected power button pins on the mainbord.
It waits 45 sec. when ignition key turn off and makes shut down via connected power button pins on the mainbord.
I think that it will be ok for Rpi too. I only need connect it's two wires to GPIO 3 and ground.


I think this method will work. What do you think?
Probably but I can't say for certain without the spec and circuit diagram for that PSU. Do not feed anything more than 3.3v into GPIO 3 as doing so will break the Pi.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

cecul
Posts: 5
Joined: Tue Nov 03, 2020 1:24 pm

Re: Power on / off button for Pi

Thu Nov 05, 2020 1:44 pm

thagrol wrote:
Thu Nov 05, 2020 10:02 am
If you do a proper shutdown there shouldn't be any problems. If you don't, expect some.
I mean that won't be problem for car battery.
thagrol wrote:
Thu Nov 05, 2020 10:02 am
Probably but I can't say for certain without the spec and circuit diagram for that PSU. Do not feed anything more than 3.3v into GPIO 3 as doing so will break the Pi.
Did i misunderstood? I won't feed any power GPIO 3. PSU will make momentery short circuit GPIO 3 and ground. Just like pushing to button in your method. I will power the RPI from PSU 5V. pin. As you know, ATX PSU provides 5V too.

User avatar
thagrol
Posts: 4978
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Power on / off button for Pi

Thu Nov 05, 2020 1:59 pm

cecul wrote:
Thu Nov 05, 2020 1:44 pm
thagrol wrote:
Thu Nov 05, 2020 10:02 am
Probably but I can't say for certain without the spec and circuit diagram for that PSU. Do not feed anything more than 3.3v into GPIO 3 as doing so will break the Pi.
Did i misunderstood? I won't feed any power GPIO 3. PSU will make momentery short circuit GPIO 3 and ground. Just like pushing to button in your method. I will power the RPI from PSU 5V. pin. As you know, ATX PSU provides 5V too.
No misunderstanding. That was just a note of caution. I've no idea what circuit that PSU uses to simulate the power button press.

The PC motherbaord connector for the power button (as you probably know) is a two pin header. One pin is pulled high, closing the switch pulls it low which tiriggers the power up, shutdown, or hard power off. If I were me, I'd be checking what the PSU does with a multimeter (or scope if you have access to one) just to be sure it Won't put 5v on GPIO 3.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

cecul
Posts: 5
Joined: Tue Nov 03, 2020 1:24 pm

Re: Power on / off button for Pi

Thu Nov 05, 2020 3:04 pm

These 2 pins isn't on ATX socket and doesn't feed any power from two pins to power buttons on the mainboard. It only momently closes the circuit and then releases. But you right, i will check it again to be ensure.
Attachments
PSUPin.jpg
PSUPin.jpg (94.83 KiB) Viewed 888 times

cecul
Posts: 5
Joined: Tue Nov 03, 2020 1:24 pm

Re: Power on / off button for Pi

Fri Nov 20, 2020 9:36 am

A company that makes some electronic products automotive in Turkey and i know their chief engineer. I told him i need a relay that will make this:

It should has constant 12 V, ACC 12 V, ground as input and 2 contacts as output.
It should wait 10 sec. when ignition key turn on and then should make short sircuit 0.5 sec in output contacts.
It should wait 45 sec when ignition key turn off and then should make short sircuit 0.5 sec in output contacts.
He said that they can make it and will be ready 2 weeks later.

So if RaspPi's GPIO 3 and ground pins wired to relay's output contacts, auto power on-shutdown issue will be fixed.

I just want to know your ideas guys. What do you think about timings? Power on, shutdown and momentery short sircuit timings are ok?

This is the company https://eticaret.elo.com.tr/ But only Turkish

moeztrigui153
Posts: 1
Joined: Tue Mar 16, 2021 9:05 am

Re: Power on / off button for Pi

Tue Mar 16, 2021 12:15 pm

Try using an spi adc instead of i2c one

Gouper
Posts: 1
Joined: Tue May 11, 2021 12:02 pm

Re: Power on / off button for Pi

Tue May 11, 2021 12:15 pm

Hey Fellow Tinkers,

I have a question concerning on/off buttons for my Raspberry Pi project.

I have an old TEAC CD player that I'm using to house my Raspberry Pi 3, Khadas Tone Board, DVD Drive (sata) and a possible 5 inch display later.

My question is:

My on/off button on my TEAC is a click style 4 pin button. If I buy a 110v to dual 12v and a 12v to 5v 3amp down step can I integrate my TEAC power button to turn my raspberry PI on and off safely?

I can't find where to put pics on discussions. This might be easier if shown.

emma1997
Posts: 1525
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Power on / off button for Pi

Tue May 11, 2021 9:50 pm

I don't know what purpose a DC converter would have here. Is the button on a running PCB? If not just wire it to GPIO3.

If the button is and is simply grounding a 3.3v pullup then no problem placing it in parallel to Pi GPIO3 power toggle pin. If higher voltage or part of key matrix (unlikely) then no-go. I have several devices like set-top-box and PC wired like that for a long time now working like a charm. Some separated by several meters.

I hate having to switch multiple appliances independently. Sometimes had to use an IR LED to turns things on/off if basic wire don't work.

User avatar
davidcoton
Posts: 6246
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Power on / off button for Pi

Tue May 11, 2021 10:01 pm

Remember that shutting down a Pi is a two-step process -- software shutdown followed by remove power. There is no inbuilt way to do that from a single control, but a read-only OS and no writable storage may make shutdown unnecessary before poweroff. Not likely for media centre apps.

EDIT:typo
Last edited by davidcoton on Tue May 11, 2021 10:44 pm, edited 1 time in total.
Location: 345th cell on the right of the 210th row of L2 cache

emma1997
Posts: 1525
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Power on / off button for Pi

Tue May 11, 2021 10:20 pm

Only applications running off small battery would need power totally removed. The idle current even Pi4 is so low just pennies a year. IME fine for big batteries like car too.

Normal trick is a PFET circuit to shut down completely. If DC converter is involved then using the enable pin on that serves same purpose at a fraction the cost and parts count.

RESUME feature of media players is very important to me so read-only OS not an option. I wish they would fix that bug in VLC so I don't have to spend 5 minutes finding where the movie left off every time. Normally mine are on 24/7 so not a huge problem. Unless somebody (you KNOW who you are!) likes to pull plugs to vacuum the rug.

drtechno
Posts: 241
Joined: Fri Apr 09, 2021 6:33 pm

Re: Power on / off button for Pi

Wed May 12, 2021 6:08 pm

I made one by just building the gate circuit out on the 4B. While I was at it I made a simple control for a pwm
fan viewtopic.php?f=41&t=311477

alphanumeric
Posts: 2918
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Power on / off button for Pi

Wed May 12, 2021 7:09 pm

davidcoton wrote:
Tue May 11, 2021 10:01 pm
Remember that shutting down a Pi is a two-step process -- software shutdown followed by remove power. There is no inbuilt way to do that from a single control, but a read-only OS and no writable storage may make shutdown unnecessary before poweroff. Not likely for media centre apps.

EDIT:typo
Except on a Pi 400, It removes power from the GPIO and USB on shutdown. With just the one key combo, Fn F10.

This will do the two process for you.
https://shop.pimoroni.com/products/onoff-shim
It was originally designed for Pi 3B's and earlier though. Should be fine with a Pi 4B as long as your not close to drawing 2.5A.

alphanumeric
Posts: 2918
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Power on / off button for Pi

Wed May 12, 2021 7:13 pm

On my headless setups I usually have two switches. A pushbutton to do the OS shutdown. And a latching switch to kill the power. If its battery powered the latching switch disables my boost converter and leaves just the battery charge circuit active. .

Return to “Beginners”