Simple Solenoid Driver
Recently I have been experimenting with CO2 injection for my planted aquarium and was interested in using a solenoid valve to control the CO2 flow, turning it off at night when the plants don’t need it. Since I have just upgraded my lighting to a DIY LED setup it would seem sensible to use an Arduino with a Real Time Clock to control both the lighting (allowing for gradual sunrise/sunset emulation) and the CO2.
In doing some research I found a very interesting article about the proper way to drive a solenoid which drastically reduces power consumption. The original article can be found here:
I encourage you to read it as it goes into a lot more detail and has some further revisions of the design that add features over and above the basic design I have implemented.
I have actually created two videos about this circuit. The first is the full version – it’s quite long (around 50 minutes) because it contains all the mistakes, debugging and thought processes that go along with building a circuit like this. Choose this video if you have some time and want to take the journey along with me and laugh at my bumbling approach.
The other video is a more condensed look at the circuit, with all the mistakes and most of the bumbling edited out. Its about 20 minutes. Choose this one if you just want to quickly learn how the circuit works, see it working on a breadboard and aren’t interested in following my stream of consciousness as I build it.
Below is the circuit diagram. Please note that capacitor C2 is the smoothing capacitor I had to add on to the circuit at the end of the video. It may not be absolutely required depending on your power supply, but it is probably a good idea to include it for good measure.
Also note that you should choose the value for resistor R1 depending on the resistance of your solenoid and the voltage required to hold it open reliably. I explain how to do this in my video.