Timer to control a switch - long term, battery powered, tiny

Discussion in 'Embedded Systems and Microcontrollers' started by Cityboy516, Jun 17, 2015.

  1. Cityboy516

    Thread Starter New Member

    Jun 17, 2015
    5
    0
    Hi

    I am looking to create a battery powered time switch.

    The goal is for it to be pre-programmed to switch a small circuit on / off based on different dates / times for a number of years in advance. Ideally it should be able to run for years on a battery - but I don't know if that is possible.

    Unfortunately I have absolutely no previous experience with embedded electronics. My programming knowledge would be described as beginner (although not entirely no experience here).

    My questions are:
    - does something like this exist off the shelf (that can be easily programmed)?
    - given my pretty limited experience in this area is it viable for me to create this myself?
    - if so, where would I be able to find out how to do this?
    - if not, where would I go to try and get it made for me (at a reasonable cost :p)

    I really appreciate any answers
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,395
    1,607
    Hi Cityboy, welcome to the forums!

    It doesn't sound impossible but it may be a struggle, mostly concerning running for "years" off a battery.

    With "limited" expierence I would look at some of the building block pre-made boards such as the Arduino line, combined with either a "shield" (the name for other pre-made boards that plug into the Arduino) or other pre-made and wired on boards.

    There are devices (DS3231 for one) you can get cheap off EBay that provide very a accurate real time clock with alarms ou can set.

    The controller (arduino or such) should spend most of it's time in what is called "sleep" mode. Sleep means the device is on but not running so it draws a small current. The timer has an alarm function and can make a signal to wake up the controller so it runs and sets the switch.

    Hopefully someone more familiar with the Arduino will wander by and make specific recomendations. I'm a Microchip PIC guy, I would use one of those hands down but I don't think it is a good choice for a beginner for a one-time project such as yours.

    The big questions I have for you is how big is your battery (range from a couple of AA batteries to a car battery), and what is the load you are switching (as the switch will need some power too).
     
  3. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    Another important factor: how accurate must the timing be? High accuracy over a year or more would involve additional cost/complexity.
     
  4. Cityboy516

    Thread Starter New Member

    Jun 17, 2015
    5
    0
    Hi ErnieM

    Thanks for taking the time to reply. I clearly have a steep learning curve if I actually want to do this!

    With regards the Arduino / DS3231 route, are both necessary? if the DS3231 keeps the tima and has an alarm can it not be set such that the "alarm" simply triggers the switch to connect / disconnect as needed?

    With regards your two questions:
    -I was hoping for it to run off a couple (or a few) AA batteries. Certainly not something like a car battery. It seemed to me (maybe naively) that if e.g. a Casio watch can run for years off one battery and all i am looking to do is keep the time and connect / disconnect a switch at a set of preprogrammed times, then it should similarly be possible on a level of power of similar magnitude.

    - I don't know what the switch load is. To be honest I don't really know what switch load *is*. The switch is in the door of a fridge and detects if the fridge door is open or shut.
     
  5. Cityboy516

    Thread Starter New Member

    Jun 17, 2015
    5
    0
    Hi Alec

    Thanks for your reply.

    I was hoping for what is probably pretty good accuracy. i.e. minutes per year (or several years) rather than hours / days.
     
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,395
    1,607
    The DS3231 and similar are amazingly inexpensive and accurate clocks, good to a few minutes a year. However, they need to be set once they turn on so the starting time is correct. (Note: I forgot this before, some additional circuitry (display, buttons) are necessary.)

    We seem to mean different things when we say "switch," which is normal as it is a very generic word. The switch in the door is connected to the light bulb inside, which means it is opening and closing the AC line to the bulb. Are you leaving the bulb connected or are you repurposing that switch?

    For giggles once I built a "you left the fridge door open dummy" detector which just consisted of a chip, light detector, a buzzer, a pair of resistors, and a coin cell battery. It could run for a year off that, if you didn't make it beep too much. However, the chip was one of those PIC computers I mentioned in passing.

    Can you tess us more about what your proect is doing? Why is it turning that switch on and off?
     
  7. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Get one like this, and hack into it.

    I have a couple here where the motorized valve is bad, but the timer runs fine on AAs. I could send you one for free if you pay shipping. If you had put a country in when you registered for this web site, I might have had a clue if it was worth making this offer.
     
  8. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Now I am confused? Are you trying to record the cumulative time how long the door is left open? What does this have to do with the timer?
     
  9. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    The typical timing error of many real-time clock/calendar modules controlled by a 32.768kHz crystal is 20 parts per million, which equates to about 10 minutes per year. Is that good enough?
    I'm puzzled as to why you want that sort of accuracy to simulate a fridge door being opened :confused:.
     
  10. JohnInTX

    Moderator

    Jun 26, 2012
    2,348
    1,029
    I don't want to hijack the thread but Orbit is pretty good with free replacements - even on older out of production stuff. This spring I collected all of my bad irrigation stuff and had a bench full of bad Orbit things, including timers and valves. Called them to see if anything could be done and they replaced everything for free. Kind of junky stuff but great customer service.
     
  11. Cityboy516

    Thread Starter New Member

    Jun 17, 2015
    5
    0
    Thanks for all of the replies.

    Unfortunately the *why* of this one is a little complicated to explain on a forum. Suffice it to say that I am trying to get the fridge to think the door is shut when it really is not. If anyone is really that interested I would be happy to explain to them off the forum.

    ErnieM - I am not sure if the switch is connected directly to the AC line to the bulb or if it is just a sensor connected to the fridge computer which in turn controls the light. I suspect the latter as if you flick the switch it also triggers the fan inside the fridge. I plan on leaving the light, fan etc. all intact the only thing I am trying to do is fool the fridge into thinking that the door is shut at specific times / dates.

    MikeML - I am based in the UK. The device you linked to seems to be more of a daily / weekly timer. Is that correct? What I am trying to do is set specific dates / times up to years in advance.
     
  12. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    I suspect you'll find it difficult to source an off-the-shelf timer which enables you to set multiple arbitrary times over that period. So a custom-built unit using a microprocessor seems inevitable.
     
  13. Cityboy516

    Thread Starter New Member

    Jun 17, 2015
    5
    0
    Hi All

    I have got hold of an Arduino and am busy writing the code necessary for this project (fairly time consuming). However I am coming back to what was essentially my initial question (although I now understand my question better).

    The Arduino will use almost no power to figure out when to switch on and off, which is great, however if I use e.g. a relay to do the actual switching then it will need to draw current all of the time that the switch is on (or off depending how it is wired) just to keep the switch in that position.

    Is there any other kit I can use that will only use a small amount of current to turn the external switch into the on or off position, but not use any current to actually keep the switch in whatever position it is presently in?

    I suppose it would need to have two inputs (as opposed to a relay that only has one), one to switch it the external circuit on and one to switch it off. when neither input is active then the external circuit would simply remain in whatever position it currently sits.

    Does anyone know of anything I can use that would do this?
     
  14. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    Depending on the load you want to switch, a MOSFET may do what you want.
     
Loading...