I have an Ultrasonic Humidifier that I use to humidify my shop. I have to fill its 2-gallon tank daily which is becoming a nuisance. Rather than connecting it to a larger tank, I have opted to automate the process.

I have two liquid level switches (seen here) which can be set up for NO or NC operation depending on whether it is facing up or down.

I have installed one switch at the top of the humidifier's tank and the other switch at the bottom. I am looking to construct a logical gate using transistors that will signal the water solenoid valve to open when the water level drops below the bottom liquid level switch and close the water solenoid valve when the level rises above the upper liquid level switch.

Based on my limited knowledge and the research I have done, I need to construct a logical OR gate using transistors (like this one.)

Am I on the right track so far?

  • 2
    \$\begingroup\$ What about using a toilet filer valve and not bother with any electronics? \$\endgroup\$ Mar 11, 2013 at 20:56
  • \$\begingroup\$ There is very little room inside the tank due to the way it was designed. It would not be able to hold a toilet float. \$\endgroup\$ Mar 11, 2013 at 20:57

2 Answers 2


What you want is more than a gate. A gate is combinatorial, meaning that its output is simply a function of its inputs. It has no memory. Whenever you have the same inputs, you'll always have the same output.

But your requirement is different. When the tank is half empty, and one switch is on, and one is off, should the tank be filling or not? Answer, it depends. This cannot be achieved with a simple gate.

What you need is a Set Reset Latch (SR-Latch). This latch is made from two gates wired together.

SR Latch

A high pulse on the S (set) input flips the output into one state. The state stays until a high pulse on the R (reset) input flips it the other way.

So, how does this work in practice? Imagine the tank is half full, and the switches are wired so that their output is low when the tank is half full. The latch is currently in the 'not filling' state.

When the water level reaches the bottom switch, it causes the output to go high, flipping the latch into the 'filling' state. The filling continues, even as the water level goes back above the bottom switch, and continues until the water level reaches the top switch. This causes the top switch to flip the latch back into the 'not filling' state.

Now, you wouldn't bother to make this latch out of individual transistors. It would be simpler to buy a chip containing NOR gates, like the 4001 Quad NOR chip. These cost less than 50p.


Alternatively, make it even easier. Buy a chip with an SR latch already on it, like the 74LS279:


This chip actually contains NAND based latches, rather than NOR based ones. The concept is the same, but the inputs are active low, rather than active high.


So how do you use the latch to switch a 120v AC valve? You certainly don't need to make a latch from 120v transistors! You can use a low voltage to switch any kind of high voltage or current, you just need the right kind of interface components.

You should use a relay to switch the high voltage, and a transistor to interface between the latch and the relay. See the answer to another question: How can i drive a 5v 120VAC 80mA with 15A contacts with a raspberry pi? for details about how to do that. There you will see a diagram. On the diagram, where is says 'GPIO', that's the signal from the output of your latch. Where it says L_COIL, that's the coil of your relay. You'll need a relay which can be energised with, say, 5v. But the contacts need to be rated for 120v AC.

  • \$\begingroup\$ You were a tremendous help. Now, my question is, given that I will be switching very low current 120V AC and the maximum voltage of that chip is 7V, I assume that I will need to make one from scratch from higher power transistors. Correct? \$\endgroup\$ Mar 11, 2013 at 21:59

I would use a single switch so that you don't need any electronics at all. I have almost the exact same problem, except in my case it's a sump pump in a bucket used for a sink in the basement that is below the waste water outflow pipe level. The pump gets turned on when the level reaches near the top and off when it gets near the bottom.

The switch came from a hardware store and was sold as a switch for sump pumps. I used a float in the bucket to push a threaded rod up and down with the level of the water. The float it a small glass jar with the rod thru its metal cap, held by a nut on either side. Two sets of back to back nuts are adjusted so that one flips the switch to on when the level gets high and the other to off when the level gets low. This has been working great for something like 20 years without me having to mess with it. In your case you'd mount the switch upside down from what I did so that it goes off when pushed high and on when low.

  • \$\begingroup\$ Thank you for the answer. Since your post, I have researched these types of switches and have concluded that that are most likely too large to fit in or on this device and its tank. I will probably continue looking into your option, however, I would still like to know how to complete this project using the other electronic method so that I can compare the two. \$\endgroup\$ Mar 11, 2013 at 21:08
  • \$\begingroup\$ @Jordan: The only part required to be inside the device is the float with a rod sticking up. The switch and the nuts on the rod to activate the switch can be well above the tank. \$\endgroup\$ Mar 11, 2013 at 21:32
  • \$\begingroup\$ Your method could work quite well, I could use a very small float on the end of the rod. Thanks for your help. \$\endgroup\$ Mar 11, 2013 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.