I have an LM2596 module and a 12V lead-acid battery which I would like to use to power a RPi zero and control with an ATtiny85 in a project which requires the RPi to be active 30s and then shut off 270s.

My question is: How do I toggle BAT1 on or off using as little current as possible?

In my project I want the RPi to only turn on if there is enough light outside, so I am using a photoresistor for that.


simulate this circuit – Schematic created using CircuitLab

So, to clear things up. The photoresistor (U4) is powered by PIN2 only when required to read the light level and PIN3 is used as an analog input on the ATtiny. I don't know how to switch BAT1 from my microcontroller.

I've measured the power consumption of the RPi zero which is at max about 150 mA and on average about 60 mA.

Photo of the LM2596 module I am using:

enter image description here

  • \$\begingroup\$ Do not just shut off the power to the RPI you will corrupt what ever is on the SD card and could possibly cause damage, just code a bit of Python to trigger the inbuilt shutdown function, then the pi will shutdown naturally. Not like a car being driven into a wall.. \$\endgroup\$
    – Alex
    Aug 25, 2016 at 8:43
  • \$\begingroup\$ @Alex I've already got that covered, when the RPi starts up it will read everything into memory using tinycore for RPi and when it has performed its computational task it halts (this operation should never take more than 30s) so it will not corrupt anything. Besides the filesystem is mounted readonly. \$\endgroup\$
    – Linus
    Aug 25, 2016 at 9:53
  • \$\begingroup\$ Its never a good idea to just remove the power from something thats running. \$\endgroup\$
    – Alex
    Aug 26, 2016 at 12:26

1 Answer 1


Since the crux of the question is how U1 can control power to the RPZ, and U1 has its own power source, the answer is simple - use one of the free pins on U1 to control U2. U2 is a LM2596, which has a control pin (pin 5 on the TI datasheet), so:

  1. Wire up pin 5 of U2 to, say, PIN4 on U1 (if PIN4 is meant for that function).
  2. Connect the grounds of the two circuits for common potential.
  3. Program U1 PIN4 to control the power regulator as desired.
  • \$\begingroup\$ I have the LM2596 module, do I need to solder a wire on pin 5 of the actual regulator itself or is there a pin on the module already? \$\endgroup\$
    – Linus
    Aug 24, 2016 at 20:49
  • 1
    \$\begingroup\$ Although 'open' will work, chances are pin 5 is actually connected to ground (In -). If it is grounded (likely) you would have to carefully lift the pin from where it is connected or otherwise break the connection to ground, and then attach a wire to pin 5. You can put a 3K resistor in series. \$\endgroup\$ Aug 24, 2016 at 21:09
  • \$\begingroup\$ Oh, I think I know someone who can help with that. Do I have to connect the grounds (the lithium battery gnd and the 12v battery gnd) for it to work? \$\endgroup\$
    – Linus
    Aug 24, 2016 at 21:12
  • 1
    \$\begingroup\$ Yes, BAT1 and BAT2 negatives should be tied together for this to work. \$\endgroup\$
    – Smith
    Aug 24, 2016 at 21:24
  • \$\begingroup\$ @Smith According to the datasheet when the LM2596 is turned off it draws about 80 μA which is 16 times more then the AVR in standby mode. And since the LM2596 only needs to be on for 30s and off for 270s, the AVR would need to have PIN4 high for 270s. Wouldn't using a transistor to switch the 12V souce work? The raspberry pi zero consumes max about 150 mA. \$\endgroup\$
    – Linus
    Aug 24, 2016 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.