Jump to content

Banner.jpg.b89429c566825f6ab32bcafbada449c9.jpg

Help please - software controlled 12v timer?


michaelmorris

Recommended Posts

I currently run two Watec 902 cameras for capturing videos of meteors.  Each camera is turned on every evening and and off in the morning with plug-in mains timers, which are an absolute pig to adjust.  As the computers that run the capture software are on 24/7, it would very convenient for me to have a simple piece of Windows software that controlled a relay to turn the cameras on and off at user-defined times each day. As the year progresses, I could very simply change the on and off times from the computer (Using light sensors to turn the cameras on and off is not practical in my situation).

This sound really simply, but for the life of me I can't find anything out there that does this.  Does anyone know of anything out there that will do this?

Thanks

Link to comment
Share on other sites

1 hour ago, Cornelius Varley said:

I also found this which I believe is a programmable device which doesn't require a computer to control it.

Thanks. That is more like the sort of thing that I am after, but the software doesn't seem to have simple "turn it on at xx pm and turn it off again at xx am" functionality.

Also, the point is that I DO want to control it from my Windows PC

Link to comment
Share on other sites

Raspberry Pi + Energenie 314-RT + Energenie Smart plugs + Domoticz(.com) 

Runs standalone with full scheduling. Controllable from any device on the same network via web interface. Also linkable to Apple HomeKit / Google Home etc via plethora of plugins.

Link to comment
Share on other sites

37 minutes ago, Marci said:

Raspberry Pi + Energenie 314-RT + Energenie Smart plugs + Domoticz(.com) 

Runs standalone with full scheduling. Controllable from any device on the same network via web interface. Also linkable to Apple HomeKit / Google Home etc via plethora of plugins.

Thanks, but that sounds complicated and/or expensive. 

Ideally, I just want to be able to plug in a simple relay board or at worst an Ardunio + relay board and a simple Windows interface to set the start and end times.

Link to comment
Share on other sites

Well....  

If you feel confident enough, the in-built way for Window$, is to use Task Scheduler (https://technet.microsoft.com/en-us/library/cc748993(v=ws.11).aspx?f=255&MSPPError=-2147217396)

This can be configured to run a program at any time\frequency etc.  I use it all the time to produce & mail system reports....

Link to comment
Share on other sites

1 hour ago, Dr_Ju_ju said:

Well....  

If you feel confident enough, the in-built way for Window$, is to use Task Scheduler (https://technet.microsoft.com/en-us/library/cc748993(v=ws.11).aspx?f=255&MSPPError=-2147217396)

This can be configured to run a program at any time\frequency etc.  I use it all the time to produce & mail system reports....

Thanks. I don't need something to turn on and off software, I need something to turn on and off the hardware (camera and cabinet heater). I can't leave these running all day as direct sunlight falling onto the very sensitive camera chip is likely to damage it.

Link to comment
Share on other sites

On 12/24/2017 at 20:57, michaelmorris said:

I've tried one of those already. Great hardware but I can't find timer software to support it.

I have an Orange-Pi that handles the security for my front door. One of the pieces of software that runs will determine when the PIR which detects movement should turn on the outside lights. These lights are a 12V LED strip that is controlled by a MOSFET connected to a GPIO pin on the *Pi.

Here's the code. Please don't laugh (even though it is Python)

#!/usr/bin/python

# Create the /tmp/darkness files that determines whether the outside LED
# strip should be lit when the PIR detects movement.
# This script is designed to be called from cron just after midnight and during the day
# It works out which event: dusk of dawn is due next and sleeps until that time.
# It then creates or removes the darkness file

import ephem
import datetime as d
import time
import os, sys
import psutil
import socket
import logging

darkness_file='/tmp/darkness'

logging.basicConfig(filename='/tmp/darkness.log', level=logging.INFO, \
                    format='%(asctime)s %(message)s', datefmt='%d-%b-%Y %H:%M:%S')

# check to see if there is an instance running already

lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)

try:
  lock_socket.bind('\0' + "darkness")
  logging.info("Started")
except socket.error:
  logging.info("Lock exists, another instance is already running, exiting")
  sys.exit()

while os.path.exists('/tmp/time_not_set'):
  logging.info("Waiting for time to be set ...")
  time.sleep(60)


o=ephem.Observer()
o.lat='37.6'
o.long='-2.78'

s=ephem.Sun()

s.compute()


dawn=o.next_rising(s)
dusk=o.next_setting(s)
last_dusk = o.previous_setting(s)
logging.info("Calculated next dawn at %s, next dusk at %s", str(ephem.localtime(dawn)), str(ephem.localtime(dusk)))
logging.info("Last dusk was %s, it is now %s", str(ephem.localtime(last_dusk)), str(ephem.now()))

todawn = dawn - ephem.now()
todusk = dusk - ephem.now()

# Of the box is rebooted after dusk, the light should be made to turn on when the PIR fires.
# We need to check if the current time is past the dusk time and to create the darkness file
# if it is

m = psutil.Process(os.getpid()) # me - this process
p = psutil.Process(1)           # init (boot time)

if (m.create_time()-p.create_time()) < 180:
  if (ephem.now() > last_dusk) and (ephem.now() < dawn):
    logging.info("Running during the night, soon after boot")
    if not os.path.exists(darkness_file):
      logging.info("There is no darkness file, creating one")
      df=open(darkness_file, 'w')
      df.close()


if todusk < todawn:
  secs = int((todusk % 1) * 86400)
  logging.info("Next event is dusk at %s in %d seconds",str(ephem.localtime(dusk))[:19], secs)
  time.sleep(secs)
  df=open(darkness_file, 'w')
  df.close()
  logging.info("Written /tmp/darkness")
else:
  secs = int((todawn % 1) * 86400)
  logging.info("Next event is dawn at %s in %d seconds",str(ephem.localtime(dawn))[:19], secs)
  time.sleep(secs)
  if os.path.exists(darkness_file):
    logging.info("Deleting darkness file")
    os.remove(darkness_file)
  else:
    logging.info("No /tmp/darkness file to remove")

You'll have to change the Lat / Long for the code to work out your own times of darkness. It does have one flaw that I am aware of: if the box is rebooted during the day, the lights come on.

Link to comment
Share on other sites

14 hours ago, michaelmorris said:

Thanks. I don't need something to turn on and off software, I need something to turn on and off the hardware (camera and cabinet heater). I can't leave these running all day as direct sunlight falling onto the very sensitive camera chip is likely to damage it.

Your scheduled scripts would do this, is rather the point, Mike

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.