I am building a RC car with a Raspberry Pi 3, and I would like to power the Raspberry with a battery. However, when the Raspberry is off, I would like to switch from the battery powering the Raspberry, to the battery being powered by a photovoltaic cell.

The battery has only two wires through which you can charge or discharge it. In this case, I cannot charge the battery while it is discharging.

Considering that even when shut down, Raspberry Pi draws some current, how could I determine that the Raspberry has turned off, so I can switch off power between the battery and Raspberry, and switch on power between the solar cell and battery?

2 Answers 2


You can use the following to signal when the Pi has shutdown. This is commonly used to control power to the Pi.

Name:   gpio-poweroff
Info:   Drives a GPIO high or low on poweroff (including halt). Enabling this
        overlay will prevent the ability to boot by driving GPIO3 low.
Load:   dtoverlay=gpio-poweroff,<param>=<val>
Params: gpiopin                 GPIO for signalling (default 26)

        active_low              Set if the power control device requires a
                                high->low transition to trigger a power-down.
                                Note that this will require the support of a
                                custom dt-blob.bin to prevent a power-down
                                during the boot process, and that a reboot
                                will also cause the pin to go low.

I have done a lot of remote weather sensor installations and RC model flying, my advice would be to connect the charger to the battery all the time. There's no point turning the charging on or off, and if you're lucky you may run your electronics right off the charger, giving your battery the rest.

Could not imagine any reason, why the charger cannot be always connected to the battery.

  • I am not talking about a charger, but about a solar cell that would charge the battery (quite slowly). And my issue is that the battery looks like this. It is charged through the same wires it is used. I need to find a way to switch off current to the raspberry when it is of, and switch on current from the solar cell to the battery. Jul 4, 2018 at 8:41
  • @GeorgeLazu most of the batteries are charged through the same wires. you may easily keep the solar cells connected to the battery ALWAYS, this won't break anything, unless you're doing something wrong. could you please explain your motivation behind the switching solar cell on and off ?
    – lenik
    Jul 4, 2018 at 8:55
  • I figured if the current is flowing from the battery to the raspberry, connecting the solar cell to those wires wouldn't work, as I am connecting to power sources to each other. How should I proceed with this circuit? Jul 4, 2018 at 10:01
  • @GeorgeLazu please, connect your charger and everything else to the battery, don't worry about switching on/off, it should work just fine.
    – lenik
    Jul 4, 2018 at 10:04
  • I've done as you said, and it appears that the solar cell is heating up while it is connected to the battery, and also to the RaspberryPi and motor controller. Why would that happen? And would using a diode fix this issue? Sep 10, 2018 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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