Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Efficiency of indoor grow light timer

by Marshall (Abbot)
on Nov 14, 2017 at 09:05 UTC ( #1203340=note: print w/replies, xml ) Need Help??


in reply to Efficiency of indoor grow light timer

Hi stevieb!
I do figure that you are way over-thinking this.

To handle power-failure restarts, put a call to turn_off_lights(); in the Pi boot routine.

Schedule a chron job to run this code every 10,20 minutes, or even every hour.
Even if the Pi doesn't acquire the correct time, this should prevent the problem of the lights being on too long for multiple days.

#!/usr/bin/perl use strict; use warnings; # time off: 1800 - 0600 6PM to 6AM my $hour = (localtime(time))[2]; if ($hour >= 06 and $hour <= 18) { turn_on_lights(); #day time } else #18:01 to 05:59 avoids the hour 00 discontinuity { turn_off_lights(); #night time }
Update:
I think I had the wrong sense between day and night time before. Oops.
Here is one link to ChronTab.

I have a Raspberry PI 3. What version do you have?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1203340]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2019-06-20 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (90 votes). Check out past polls.

    Notices?