0

Activate RPi run pins from status of solar panel
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Activate RPi run pins from status of solar panel

by Callipygous on Fri Aug 02, 2019 5:20 pm

For my project I am using a raspberry pi 3a+. It is running off a battery, which is being charged by a solar panel. I want the Pi to turn on when its dark out, and turn off when its bright or the battery is low.
My thought was to handle this directly off the leads of the solar panel, but if adding a phototransistor makes it easier, I am open to that. I am planning on using this Charging board. I was thinking that for turning it off I could use the low battery indicator and the lead off the solar panel to GPIO pins programmed to request shut down. I don't know what that wiring would need to look like. Solar panel + and - wired onto coil of a relay, which then connects 3.3v to some input?

For turning it on I was thinking of resetting the run pins, But this gets a little tricky because I want it to trigger when the solar panel turns off, not on. Also, my understanding is that connecting the two run pins turns the Pi off, and then disconnecting them turns it on. I don't want to turn the pi off via run pins when the solar comes on, because I've heard that would lead to corruption. So when the solar panel turns off I need it to momentarily connect, and then disconnect the run pins. One of my friends has suggested I could create a one-shot functionality by using 2 relays. One would connect the run pins, the other would latch itself on and turn off the other relay. I think I understand how that would work if I wanted to trigger it when solar turns on, but I don't understand how to do it when solar turns off. I also can't seem to find reasonably priced 6v relays.

Advice on any of that, or cleaner ways to achieve it, would be appreciated. Bearing in mind the goal is to have minimal power usage when the Pi is off. So having an arduino or something control it would seem to defeat the purpose.

Callipygous
 
Posts: 6
Joined: Fri Aug 02, 2019 4:58 pm

Re: Activate RPi run pins from status of solar panel

by adafruit_support_mike on Sat Aug 03, 2019 3:33 pm

A regular LiPo charger can't use a solar panel efficiently. It will sort-of work, but you'll only get about 10% of the energy you could.

The problem is that a solar panel's output voltage and current are related to each other. The current drops dramatically if you set the output voltage too high, and the voltage drops dramatically if you try to draw too much current. To use a solar panel anywhere near efficiently, you have to find the combination that supplies the highest current at the higest voltage, called the 'Maximum Power Point'. The MPP changes with the amount of light hitting the panel, so the circuit to maintain that balance is called a 'Maximum Power Point Tracker', or MPPT.

Our Solar LiPo Charger has a good approximation of a full MPPT for 6V solar panels:

https://www.adafruit.com/product/390

You could connect the DCIN pins on that to a 3.3V voltage monitor:

https://www.adafruit.com/product/3428

and use the output from that to control a PowerBoost's EN pin.

With the Solar Charger keeping the LiPo charged, you don't need the PowerBoost 1000C's built-in LiPo charger, so you could swap over to a PowerBoost 1000 Basic:

https://www.adafruit.com/product/2030

adafruit_support_mike
 
Posts: 58799
Joined: Thu Feb 11, 2010 2:51 pm

Re: Activate RPi run pins from status of solar panel

by Callipygous on Sat Aug 03, 2019 5:43 pm

Ok, I'm not familiar with most of this so I want to make sure I understand.

I use your solar lipo charger to connect solar panel to battery.
At the DCIN pins (same place I am wiring in the solar panel, correct?) I connect the voltage monitor.
Coming out of the load JST connector on the charger I have my voltage booster to take the 3.7v battery up to the 5.2v my pi needs.
But then on that voltage booster I attach the output of the of the voltage monitor to its enable pin, which means when voltage at the solar panel drops too low it will turn off the voltage booster, effectively killing the power to my pi?

Callipygous
 
Posts: 6
Joined: Fri Aug 02, 2019 4:58 pm

Re: Activate RPi run pins from status of solar panel

by adafruit_support_mike on Sun Aug 04, 2019 1:25 pm

Callipygouws wrote:I use your solar lipo charger to connect solar panel to battery.

Yes.

Callipygouws wrote:At the DCIN pins (same place I am wiring in the solar panel, correct?) I connect the voltage monitor.

Yes.

Callipygouws wrote:Coming out of the load JST connector on the charger I have my voltage booster to take the 3.7v battery up to the 5.2v my pi needs.

Yes.

Callipygouws wrote:But then on that voltage booster I attach the output of the of the voltage monitor to its enable pin, which means when voltage at the solar panel drops too low it will turn off the voltage booster, effectively killing the power to my pi?

Yep.. you’ve got it.

adafruit_support_mike
 
Posts: 58799
Joined: Thu Feb 11, 2010 2:51 pm

Re: Activate RPi run pins from status of solar panel

by Callipygous on Mon Aug 05, 2019 8:56 pm

I appreciate the info about MPPT, luckily I actually have that chip you recommended and thought it wasn't what I needed because it doesn't boost the voltage, but I guess I just need to get a voltage booster to go with it.

The voltage monitor sounds handy, but I don't think I would want to apply it quite that way. For one, I have heard just turning the Pi off, rather than shutting it down, can result in corruption. I see thats actually a recommended usage for that voltage monitor though. Is corruption less of a concern than I've heard? Maybe depends on the board? The other thing is that I want the Pi to turn off when the solar panel comes on, not the other way around.

Callipygous
 
Posts: 6
Joined: Fri Aug 02, 2019 4:58 pm

Re: Activate RPi run pins from status of solar panel

by adafruit_support_mike on Tue Aug 06, 2019 9:32 pm

You can connect the voltage monitor to one of the RasPi's GPIO pins and use it to trigger an orderly shutdown.

Data corruption is still an issue with Raspbian SD cards, so you always want to shut the RasPi down properly.

You can also use a second voltage monitor connected to the center of a 1k-33k voltage divider.

The center of the divider will drop to 3.3V when the battery voltage is 3.4V, and you can use that as the shutdown signal. A RasPi still draws about 100mA after the OS has shut down, and a second voltage monitor connected directly to the battery can shut the PowerBoost down before the battery voltage can fall lower than that.

adafruit_support_mike
 
Posts: 58799
Joined: Thu Feb 11, 2010 2:51 pm

Re: Activate RPi run pins from status of solar panel

by Callipygous on Thu Aug 08, 2019 6:21 pm

How does shut down work with regards to gpio vs os? Do the gpio pins shut off after the os has shut down?
I am wondering if I could put that voltage detector between the 5v pin and ground on the RPi, and when there is no longer power at the 5v pin it would tell the booster to completely turn off power.

Callipygous
 
Posts: 6
Joined: Fri Aug 02, 2019 4:58 pm

Re: Activate RPi run pins from status of solar panel

by adafruit_support_mike on Fri Aug 09, 2019 11:16 pm

You can use code like our GPIO Halt utility to trigger an orderly shutdown when a GPIO pin goes low:

https://github.com/adafruit/Adafruit-GPIO-Halt

All you have to do is give the RasPi enough time to complete its shutdown before pulling a PowerBoost's EN pin low to disable the 5V output.

adafruit_support_mike
 
Posts: 58799
Joined: Thu Feb 11, 2010 2:51 pm

Re: Activate RPi run pins from status of solar panel

by Callipygous on Sat Aug 10, 2019 10:15 am

Thanks for all your help.
I was intending to use a GPIO pin for orderly shut down, as you describe. But you say the RPi continues to pull 100mA after the os is offline. Im walking a pretty thin line with my charging and power consumption on this project, so I'm hoping to not have that. I like your idea of turning the booster off with a voltage monitor, but if my shut down was triggered by the solar panel coming on, and the battery is still relatively high, it is going to be a 100mA drain on my charging. And actually, 100mA at the boosted 5.2v= more like 140mA coming out of my 3.7v battery, right?
To avoid that, I was wondering if the gpio pins go dead after an os shut down, and if so at what point in the shut down? If i were to put a voltage monitor on the Pi's 5v pin and ground, and the gpio pins went dead at the end of its shut down sequence, I could then have the control leg of the voltage monitor tell the booster to cut power completely. But that only works if the last thing to turn off is the GPIO.

Ive also considered just using a timed relay, but all the ones I have found seem to come with a whole module with an lcd screen and everything. Seems not ideal as my main concern is power consumption. I was hoping for one thats just a solid state relay, with a preset 10 second delay, or maybe one adjustable with a little pot knob, but I haven't found anything like that.

I really appreciate all your replies, thank you.

Callipygous
 
Posts: 6
Joined: Fri Aug 02, 2019 4:58 pm

Re: Activate RPi run pins from status of solar panel

by adafruit_support_mike on Sat Aug 10, 2019 6:27 pm

If you want more sophisticated timing control, you can use a small microcontroller like the Trinket M0:

https://www.adafruit.com/product/3500

Its ADC pins can read a voltage divider connected to the solar panel (and another connected to the LiPo), and it can generate signals that control the RasPi's shutdown and the PowerBoost's EN pin. The Trinket only uses about 9mA, so it will put much less load on the LiPo.

If you want to reduce even that current, you can connect power to the Trinket through a TPL5110 low power timer:

https://www.adafruit.com/product/3435

The TPL5110 turns on at regular intervals and connects power to a load. If the load is something like a microcontrooler, it can toggle the TPL5110's DONE pin to shut itself off until the next time the TPL5110 wakes up.

You can set the TPL5110 to wake up the microcontroller every 10 seconds or so. The Trinket will take less than a second to collect its readings and decide what to do.

adafruit_support_mike
 
Posts: 58799
Joined: Thu Feb 11, 2010 2:51 pm

Re: Activate RPi run pins from status of solar panel

by Callipygous on Sat Aug 10, 2019 7:18 pm

Oh goodness, the rabbit hole goes deeper...
The trinket looks awesome.
Ok, so 5 pins, I need one input from the battery for low voltage, and one tracking whether the solar panel is on or off. Then one pin requesting shutdown at the RPi, and one telling the booster to turn off its output. I think I'm going to skip the low voltage timer, when my raspberry pi receives voltage again it should take that as its cue to turn back on. So if I had the trinket turning on and off every 10 seconds while the pi is supposed to be off, every time the trinket turns off it would no longer be holding the EN pin low on the booster, so the pi would turn back on...I would have to use a relay or something to maintain the state while the trinket changes back and forth. Probably easier to just burn the 9mA.

Thanks again for all your help!

Callipygous
 
Posts: 6
Joined: Fri Aug 02, 2019 4:58 pm

Please be positive and constructive with your questions and comments.