erichabg
Posts: 15
Joined: Sat Jun 01, 2013 9:29 am

Let Pi remove it's own power

Wed Sep 12, 2018 7:35 am

Hello,
To monitor my mobile home I use a Pi Zero W with GPS, UMTS and a UPS with an additional Lithium ions battery.
The Pi is connected to the battery via a solid state relay.
This means that the relay needs a short voltage pulse to switch on and off (Relais has two coils one for on and one for off).
The power-on switch is operated manually. The power-off impulse should come from the pi itself (one of its GPIOs).
(The pi is measuring the voltage of the car and the lion battery and can detect when the battery has low voltage and it's time to power off.)

Now my question:
How can I proceed in order to switch off the Pi as gently as possible?
This means stopping as many processes as possible and protecting the file system from corruption before setting the appropriate GPIO, which will stop the disconnecting of the voltage. (root-fs is on sdcard)
It would be best to be able to set the GPIO directly before the message "System halted".
When is the last change to access the GPIOs?

Regards
Erich

PhatFil
Posts: 1440
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Let Pi remove it's own power

Wed Sep 12, 2018 7:50 am

Hi have you considered a simple delay circuit while i have not tried it i would bet a pint if you searched google with the term 3.3v 5 second delay circuit you will find something.. that way you can triger the event and continue with the shutdown for X seconds until the delay fires and signals the off.

the solution i use myself to power both my pi 3 and its associated stack of hdds and thier psu is tasmota https://github.com/arendst/Sonoff-Tasmota/wiki flashed sonoff basic devices configured to switch off after a 10 second delay they only need to recieve a published command via mqtt which you can host on the pi
no wires all coms done by wifi and you get a nice web interface should you wish to upgrade or change function or any settings

erichabg
Posts: 15
Joined: Sat Jun 01, 2013 9:29 am

Re: Let Pi remove it's own power

Wed Sep 12, 2018 9:39 am

Hello,
Thank You for your ideas!

Yes I have considered a delay circiut, but if it is possible to do it in software i would prefere this.

Using another micro controller to switch on/off the pi this is not an option that makes sense here (imho) because this device would consume additional power and there is also not server with running mosquitto (besides the pi) in the mobile home.

Regards
Erich

PhatFil
Posts: 1440
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Let Pi remove it's own power

Wed Sep 12, 2018 10:41 am

perhaps look at a suitable capacitor that can hold a big enough charge to keep the pi running its shutdown without the dc power? any software solution will rely on the system thats shutting down.

imho a software solution executing on a system undergoing shutdown isnt likely to perform consistently. the only way a software solution could be relied upon would be if the software was executing on a different lump of h/w to the pi a 3v3 esp8266 could piggy back of gpio and signal a system shutdown and then execute a power down and shutdown itself as a result

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Let Pi remove it's own power

Wed Sep 12, 2018 11:00 am

erichabg wrote:
Wed Sep 12, 2018 9:39 am
Hello,
Thank You for your ideas!

Yes I have considered a delay circiut, but if it is possible to do it in software i would prefere this.

Using another micro controller to switch on/off the pi this is not an option that makes sense here (imho) because this device would consume additional power and there is also not server with running mosquitto (besides the pi) in the mobile home.

Regards
Erich
Actually it is an effective option. A microcontroller can sleep on minute current (a few microamps) and wake itself up on a timer. It can run for years on a small battery. The Pi can't do that because it doesn't have such a micro-power sleep state.

klricks
Posts: 6627
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Let Pi remove it's own power

Wed Sep 12, 2018 12:30 pm

Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Return to “Other projects”