Automatic Water Timer

I was asked by a friend a while back to create a timer to turn a pool fill value off automatically.  Apparently he would turn the fill value on and walk away only to return to water overflowing everywhere.  He gave me a few parameters to follow: 10 minute timeout, easy to use, status lights, and reliable. He also said that it would be controlling a standard sprinkler valve and 24VAC would be provided.  With these guidelines in place, I began working out the details.

I initially thought about using a 555 to handle the timing and a relay to control the valve, with some AA batteries to power the thing.  I later decided that using batteries would be a problem because they would need replacing often.  Since 24VAC was provided I made a simple zener based power supply where the zener maintained a constant 5.1v supply and a resistor would drop the remaining voltage and convert it to heat.  These aren’t very efficient but they are easy to use and cheaper than a switching power supply.  I had to rule out using a simple linear regulator because the input voltage is beyond the limits.  The 24VAC input is actually closer to 40VDC due to AC peak voltage and the unloaded nature of the transformer (24VAC * √(2) + 20%). The current available to the rest of the circuit is also quite low with a zener regulator.

Most smaller relays require about 100mA of coil current which would use everything that the zener regulator could put out and then some.  The next best solution was a TRIAC or Triode for Alternating Current.  These are like an AC switch which turn on with a gate current and allow current to flow in either direction.  These are used in many applications where speed control or dimming is needed.  The only drawback is that they don’t shut off when the gate current is removed. They turn off when the current through the device also drops to zero – which makes them great for AC use.  I decided to use a NTE3047 optoisolated TRIAC driver.  That was my first mistake.  The datasheet for NTE parts are very lacking but unfortunately, thats usually all I have to choose from unless I place an order from mouser or digi-key. I’ll get back to this problem later.

Now that I have power and output figured out, I need to work on the control aspect.  555 timers are great for simple applications requiring up to a few minutes of delay.  At 10 minutes, the RC values needed would boarder the danger zone of the timer not functioning correctly due to the leakage current of the capacitor and the small charge current of the resistor.  I could have cascaded two or more timers together but that would be sloppy so I fell back on my trusty friend – the ATtiny micro controller.  This would allow me to make changes as I want without redesigning the board.

Water timer schematic

Water timer schematic

The actual control is just a single button with two LED lights – power and status.  I also added a small fuse to offer some protection. Since I’m already using a micro controller with all those fancy features, I put the ADC to good use and threw in a potentiometer.  This will allow the user to later change the timeout delay instead of keeping it fixed in software at 10 minutes.

Timer circuit board with modifications

Timer circuit board with modifications

On the software side, upon power up, the timer flashes the status light to count out the delay in minutes.  10 flashes correlates to 10 minutes.  The ADC reads the potentiometer just during the power up and calculates the delay for further use.  So to change the delay, you first unplug the timer, set the delay, then plug it back in.  This way it will hopefully prevent accidental changes and noise from changing the delay. To use the timer, you press the button once – the timer starts, the valve opens and the status light turns on.  After the delay has elapsed, the timer will shut off, valve closes and the status light shuts off.  If you want to turn it off early, then you just push the button and everything turns off.  I also made use of the watchdog timer to prevent software issues from keeping the valve open.  In the event that a watchdog reset occurs, the initial startup code will catch it, begin flashing the power LED and prevent further use until being power cycled.

Enclosure bottomFor the enclosure, I decided to print something up in ABS.  I first designed it in Sketchup then exported it to stl for printing.  I got fancy and made the button as part of the enclosure.  Enclosure topI was worried that the button wouldn’t work very well but I guess all my excess measuring paid off because it fits and functions perfectly.  I also included a lot of vent holes to allow the heat from the power supply to escape.

My initial test worked flawlessly with no load attached. I could push the button, it would turn on, push the button again and it would turn off. Great! I connected the solenoid and tried it again.  Turned it on and the solenoid violently clicked in.  I pushed the button again and – wait – the solenoid was still in… Hmmm. Its then that I remembered that TRIACs need a snubber circuit when driving inductive loads.  This is because inductors want to maintain their voltage – even when they are disconnected. So as the AC voltage input drops to zero, the inductor maintains this voltage (and current) through the TRIAC and keeps it switched on.  The snubber circuit is just a capacitor and resistor  connected across the TRIAC which acts to absorb enough current to prevent it from self triggering.  I calculated what would be needed for a snubber and installed it with still no luck.  I doubled the capacitance, then quadrupled it and finally got it to turn off.  I started to think that this NTE TRIAC was the issue and thats when I found a datasheet for an equivalent part.  It specifies that it should not be used directly for driving loads but instead should be used for driving bigger TRIACs. So, I used the wrong part.  I talked to my local electronics hangout and he had some surplus (i.e. pulled off of old boards) TRIACs that should work.

New TRIAC with a small modification to the gate

New TRIAC with a small modification to the gate

This time, the parts where TLC226T.  It is a sensitive gate TRIAC with low holding current.  This means that it needs 5mA of gate current to turn on and just 15mA of load current to keep it on. Luckily I just had to remove the wrong part and install the correct one with a small resistor hanging off of the gate.  With it installed I was now able to turn the solenoid on and off with no trouble, and no snubber either.

The board sitting all snuggly in the bottom enclosure

The board sitting all snuggly in the bottom enclosure

The circuit in the enclosure showing the terminals

The circuit in the enclosure showing the terminals

Back side of the enclosure.  I guess the vents are pointless if they are placed against the wall, but they were fun to make :)

Back side of the enclosure. I guess the vents are pointless if they are placed against the wall, but they were fun to make :)

My printer's sloppy job

My printer’s sloppy job

Testing with the solenoid in (on)

Testing with the solenoid in (on)

After everything was tested and I was confident it worked, I gave it to my friend so he could give me some feedback.

Testing with the solenoid off

Testing with the solenoid off

About a week later I got a call from him asking how to keep it on until he turned it off (no timer).  One face palm later he said he thought about it after we first talked and forgot to tell me. A simple software fix later and I had it implemented. For safety reasons (so no one would accidentally trigger this mode) I put it in right after power up.  The software checks if the button was pressed and held after counting the delay out and initiates this mode.  To signal this mode, both the power and status flash. To turn it off, you just press the button once and it goes back to idle mode – ready for the next use.  I flashed a spare ATtiny25 and brought it over and installed it.  He was up and running once again.

New micro controller loaded with the updated code

New micro controller loaded with the updated code – ready for a swap out

To finish it off, I printed up a face label and glued it down with some rubber cement.

 

Downloads

Schematic

Source File

 

11 Responses to Automatic Water Timer

  1. Pingback: DIY automatic water timer | PCB공유.COM

  2. Pingback: ATtiny Watering Timer Turns off the Water When You Forget

  3. Pingback: ATtiny Watering Timer Turns off the Water When You Forget - RaspberryPiBoards

  4. Pingback: ATtiny Watering Timer Turns off the Water When You Forget - Tech key | Techzone | Tech data

  5. Pingback: ATtiny Watering Timer Turns off the Water When You Forget | Ad Pub

  6. Johnni says:

    What software did you use to create that schematic? It looks really clean and nice!

    • Kyle says:

      Thank you. I used DipTrace to create the schematic. It’s a free software suite that allows you to export your schematic to their PCB design tool so it has that added bonus.

  7. Ted says:

    Where’s the value for each component?

  8. gada says:

    same question?
    Where’s the value for each component?

    Best

  9. Pingback: Automatic Water Timer -Use Arduino for Projects

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>