2

I am building a pi project that is battery powered and is powering something through the 5V GPIO. What I want the pi to do is to start up on a button press, do its thing and turn itself off again without the intervention of the user. The thing is that since it is battery powered, it is not very efficient to keep powering the pi and the 5V peripheral. Therefore, I am looking to cut the circuit between the pi and the powerbank after shutdown. To make it fit in the encapsulation, I am looking for something relatively thin, but it can be spread out (max 1cm thick).

I have been looking online for a circuit but couldn't figure it out, so I am posting my question here. (I have little experience in eletronics)

How can I start the power supply to the pi after a button press and cut the power supply again when it did its task to save energy between tasks?

Thank you in advance for any solutions, circuit designs, or products that do this!

Qorzyking
  • 65
  • 2
  • 7

2 Answers2

3

This can be done without a lot of additional circuitry. There was a question similar to yours earlier this year, and this answer was proposed. The updated schematic shown below was subsequently prepared, and this circuitry was built and tested. (Yes - it worked.)

You've said you want the RPi to do its thing and turn itself off again without the intervention of the user. The circuit below will support that requirement, but just to be clear, your code will need to recognize when the task is completed, and issue the sudo halt command. When you are ready to re-start the RPi, you will simply press the momentary pushbutton labeled START in the schematic.

A description of this circuit's operation follows:

  • The schematic assumes that the RPi initially has no power applied; i.e. the relay contacts between pins 5 & 8 of K1 are OPEN.
  • Pressing the START push-button switch momentarily causes Q1 to conduct, which energizes the K1 relay coil between pins 1 & 16, in turn causing the relay contacts between pins 5 & 8 of K1 to CLOSE. The Vcc terminal of the Power Source is now connected to the RPi's Power Input.
  • Due to the action of the latching relay K1, the 5-8 relay contacts will remain closed until the opposing coil (pins 2-16) is energized.
  • With power applied, the RPi will boot, and begin its operations.
  • With the GPIO-POWEROFF overlay for pin 26 added to the device tree (/boot/config.txt), issuing a halt, poweroff or shutdown command to the RPi will cause pin 26 to toggle as shown in the oscilloscope trace below.
  • The logic high (3.3V) toggle at Pin 26 will cause Q2 to conduct, which energizes the K1 relay coil between pins 2 & 15, in turn causing the relay contacts between pins 5 & 8 of K1 to OPEN. The Vcc terminal of the Power Source is now disconnected from the RPi's Power Input. Since the halt command was issued, the RPi is powered down safely. 

enter image description here

enter image description here

There are other related answers and information that may be of interest - this one for example. Also, the one-button ON-OFF switch is the basis for an improved design that you may find useful. Finally, there has been some discussion of this improved design implementation on my GitHub site - if you find that interesting, feel free to participate.

I'd suggest you review these answers to get a bit of background, and let us know if you have questions.

Seamus
  • 23,558
  • 5
  • 42
  • 83
1

I only know the German Term for this: Selbsthaltefunktion The Switch S1 has to be a second relay, which is switched from the Pi. Then The PI will start-up with a press on S2, stay active untill the Pi activates the negotiated relay for S1.

Best regards, Bastian

Bastian
  • 19
  • 2