Looking to design a circuit to turn raspberry pi off at night and then back on during the day.

Thread Starter

rangertech

Joined Sep 24, 2019
5
Question Context

Our pi's are going to run off of battery, meaning, we need to conserve as much power as possible. Since the birds we are researching (chickadees) mainly feed during the day we do not need to run the pi at night. Our goal is to only run the pi during the day. We considered using a photoresistor but would prefer to use something more reliable. We need the pi to turn on at least an hour before daylight to catch early feeders and we don't want the photoresistor to get covered by the snow (we get a lot of snow!). right now our best option seems to be setting up some type of separate circuit between the pi and the battery using a combination of the following: RTC, Microcontroller (looking at the Adafruit Trinkit), Solid State Relay, or some kind of Timer IC. I have absolutely zero experience with managing power or using RTC's, SSR's, or Timer IC's and am having trouble choosing which component / methodology to use.

Tech Specs

Our nodes are currently equipped with:

  • Raspberry pi zero W
  • Dragino LoRa Module
  • RFID sensor
  • Weight sensor
  • DC-DC converter
  • 15Ah lead acid battery
 

Dodgydave

Joined Jun 22, 2012
11,285
Best option is a Photo Transistor, Tept4400, and monitor the daylight, you can set it to come on at any light level using a simple Comparator or the Adc in the micro.
 
Last edited:

Thread Starter

rangertech

Joined Sep 24, 2019
5
Best option is a Photo Transistor, Tept4400, and monitor the daylight, you can set it to come on at any light level using a simple Comparator or the Adc in the micro.
What about the photo transistor being covered by snow? The reason we have not committed to using that method is because we are concerned that the snow will reduce the reliability of our data logging system. It seems that using a timer would give us more control. What are your thoughts?
 

Dodgydave

Joined Jun 22, 2012
11,285
Timer is no good as it won't detect Real Time in daylight,,

You can put the photo Transistor inside a clear plastic box like a sandwich box,,,to prevent snowfall.
 

djsfantasi

Joined Apr 11, 2010
9,156
Point the phototransistor towards the ground. Being underneath your box, snow won’t affect it.

But, since it will be measuring reflected light, with snow cover it will trigger earlier.

I’d use a microcontroller and an RTC. Choose a microcontroller with a sleep mode, so that it uses a minimal amount of current and wakes periodically to check the time.

You could probably use the Rasoberry Pi in this manner.
 

Thread Starter

rangertech

Joined Sep 24, 2019
5
Point the phototransistor towards the ground. Being underneath your box, snow won’t affect it.

But, since it will be measuring reflected light, with snow cover it will trigger earlier.

I’d use a microcontroller and an RTC. Choose a microcontroller with a sleep mode, so that it uses a minimal amount of current and wakes periodically to check the time.

You could probably use the Rasoberry Pi in this manner.
Interesting, that might actually be a good thing if the PT triggered earlier because we would like to start the pi a little before full sunrise. I might actually test that just out of curiosity.

However, I agree with you that a microcontroller in combination with a RTC. I have been looking at some RTC modules. I am currently considering purchasing a DS3231 RTC https://learn.adafruit.com/adafruit-ds3231-precision-rtc-breakout

and using it with an adafruit trinket M0. That should solve my pi shutdown but I will still need to switch off the power going into the pi from the battery. Through many google searches I have come across Solid State Relays. Would that be a good solution for a way to digitally cut the power?
 

djsfantasi

Joined Apr 11, 2010
9,156
Interesting, that might actually be a good thing if the PT triggered earlier because we would like to start the pi a little before full sunrise. I might actually test that just out of curiosity.

However, I agree with you that a microcontroller in combination with a RTC. I have been looking at some RTC modules. I am currently considering purchasing a DS3231 RTC https://learn.adafruit.com/adafruit-ds3231-precision-rtc-breakout

and using it with an adafruit trinket M0. That should solve my pi shutdown but I will still need to switch off the power going into the pi from the battery. Through many google searches I have come across Solid State Relays. Would that be a good solution for a way to digitally cut the power?
I don’t think you need an Arduino Trinket. The Raspberry Pi has a sleep mode which pulls a minimal amount of current. I’m not sure, but I think a Pi in sleep mode will pull less current than the Trinket.

So you’d put the Pi in sleep mode when your phototransistor indicates that it is darker than you want. Periodically, it should wake up and check the light level. If it’s still dark, it will go back to sleep. If it’s light enough, it will record the birds activity. You won’t need a Trinket, an RTC or any circuitry beyond the Pi other than a phototransistor.

If you can live with periodic snapshots of the birds, the Pi can sleep during the day as well.
 

Thread Starter

rangertech

Joined Sep 24, 2019
5
The only problem with that is that the raspberry pi does not have a sleep mode or a low power setting of any kind. The closest thing to that is manually shutting down interfaces such as wifi, Bluetooth, usb ports etc...
 

djsfantasi

Joined Apr 11, 2010
9,156
The only problem with that is that the raspberry pi does not have a sleep mode or a low power setting of any kind. The closest thing to that is manually shutting down interfaces such as wifi, Bluetooth, usb ports etc...
I’m sorry. I first checked that the Pi did have a sleep mode before responding. I’m not familiar with the Pi, so felt it necessary to check.

I performed a Google search for
“Raspberry Pi sleep mode”​
and received many references. Perhaps there are different models, but to me your statement is not true.
 

Thread Starter

rangertech

Joined Sep 24, 2019
5
I am very familiar with raspberry pi's and before I heavily researched the topic I assumed a "low power" or "sleep mode" for the raspberry pi had to be a feature that already existed as well. I can assure you that the raspberry pi of any model does not come equipped with a low power mode.

The closest thing to low power is shutting down the raspberry pi. However, when it is shut down it still pulls power if it is still plugged in or connected to a battery.

I am working with the raspberry pi zero. At idle the pi zero is pulling around 30ma.

Which is why I need to come up with a separate circuit that will shutdown / wake up the pi and switch the power on and off.
 

AnalogKid

Joined Aug 1, 2013
10,987
For a timer to turn on the system approx 1 hour before normal daylight, it would have to be adjusted manually about once a month to track the change in sunrise time. If that's ok, then a CD4521 is an oscillator/divider with a very low power oscillator section. With a little gating it can produce an edge every 24 hours.

Here is a 1 Hz oscillator with around 2 uA operating current:
https://www.digikey.com/products/en...tity=&ColumnSort=0&page=1&stock=1&pageSize=25

Another approach is one of the newer, very low power PICs, but either way, once you rule out a daylight sensor, you're looking at either adjusting the timer manually or having it calculate the local sunrise time.

ak
 
Last edited:

Alec_t

Joined Sep 17, 2013
14,280
Won't simply shutting off the pi power cause any running program to crash?
Will it re-start the program properly when power is switched on again?
 

djsfantasi

Joined Apr 11, 2010
9,156
Thanks for the education. May I make one more suggestion? An ATTiny85 with a DS3231 RTC. The ATTiny does support sleep mode, you can code your timing logic and the DS3231 keeps track of the time. Here is one link I found for a similar project. There are several other projects available if you search for “ATTiny RTC module”
 
Last edited:

Andrei Suditu

Joined Jul 27, 2016
52
Best all rounder would be a cheap 8bit uC with an RTC(internal or external) and a photodiode/phototransistor/photoresistor.
You can thus set it based on a time schedule,a light intensity(can be adjusted ...limiting factor is ADC resolution and sense element sensitivity).
As for power consumption you could put the uC in sleep and wake up from time to time to check the environment.
A cheap uC is Attiny85.Widley used...Arduino compatible ....has a 10bit ADC ....temp sensor integrated...5 user IO.
You would just need a mosfet(logic level one...ex irlz44n---this may be a bit overkill since it can swithch quite a few dozens of amps in a to220 or dpak package) for the PI that't it.
Another solution would be to pin interrupt wake the uC when the outside is bright using a comparator and setting a ref value.
 

dendad

Joined Feb 20, 2016
4,452
Run the extra control micro with the RTC keeping track of the data as well as the time.
Then you can have a sunrise and sunset table, not using any light detection.
The Pi can have an output that toggles feeding a capacitor coupled diode rectifier to show the control micro it is running. Use an rectified AC coupled signal as the Pi has to be running to generate it. Do not use a hardware PWM, but a loop to toggle the pin.
The control micro can switch the power to the Pi.
An input to the Pi from the control micro tells the Pi to shutdown, and when it does, the toggled pin will stop, so the control micro will know when to safely drop the power.
 

danadak

Joined Mar 10, 2018
4,057
I have an application where as PC is shutdown as a task in Windows, at
11:00 pm, then an external micro detects sunrise via solar cell V, and
checks to see PC is off (no aux 5V), and issues a simulated power button
push. If PC does not start goes into a cycle of trigger/wait util it detects
12V is present.

I plan on expanding it to power up a heater if a few cycles of start cannot get
it going. To take care of cold weather start where PC power supplies do not
like to start up cold (probably due to capacitor effects).

Pi, if running Linux, must be a triggered shutdown procedure. Why its running
30 mA off should be investigated. USB ports still drawing/supplying power ?

Regards, Dana.
 

AnalogKid

Joined Aug 1, 2013
10,987
Why manually? A microntroller can easily be programmed to do this.
And I said that in my post. But the majority of that post was about a hand-built timer circuit - oscillator, divider, output stage - that would be much more complex if it had to track the sinusoidal change in sunrise throughout the year.

ak
 

Alec_t

Joined Sep 17, 2013
14,280
From what I read the Pi needs to be shut down gracefully under software control. Simply switching off its power supply risks corrupting the SD card :(.
 
Last edited:
Top