Controlling a Solenoid Valve with an Optical Fluid Sensor

Thread Starter


Joined Jan 10, 2019
I'm trying to control a 6V DC Solenoid Valve (here the version I currently have: with a 4.5-15.4V DC optical fluid sensor (here the version I'm thinking of purchasing: I have found examples of how to use an arduino or other micro-controller to make this project work, but I'm wondering if it would be possible to get rid of the mircro-controller and if so how I can connect these two devices in a safe way that won't decrease product life. Alternatively I could use an SPST switch instead of the optical fluid sensor, would these be connected the same way?


Joined Jul 18, 2013
I believe you will need some kind of electronic interface between the two, a small 8pin micro would do it easily and also give you other features if needed.
What function is the components performing?

Thread Starter


Joined Jan 10, 2019
I'm trying to maintain fluid level in a small 3D printing vat by opening the solenoid valve when fluid is below the sensor and closing the valve when fluid reaches the sensor. I don't need any more functionality than simply detecting fluid level and opening solenoid valve until fluid is back to predetermined level.


Joined Sep 17, 2013
You will need some electronic trickery, because the valve needs a pulse to open it and another pulse to close it, whereas the sensor gives either a high or low output according to whether the sensor is respectively dry or wet. It is not clear from the spec whether the valve operating pulse needs to be the same or opposite polarity for open and close.


Joined Apr 11, 2010
Some hysteresis will be necessary with only one sensor. Consider the case where the liquid is right at the sensor level. A small drop in the level will open the valve. But a short time later, it will close the valve. The sequence will rapidly repeat, causing the system to oscillate.

Typically there are two sensors. One for fill and one for a low level. This increases the time so that oscillation does not occur.

One could use a SR flip-flop. The upper sensor would reset the flip-flop. The lower sensor would set it. The output of the flip flop would drive a MOSFET, which in turn controls the valve