Go Down

Topic: Optocouplers or Relays for Solenoid Control (Read 3215 times) previous topic - next topic



       This is my first forum post and I'm not sure if I should be starting a new topic or joining an old one. I'm a new user to these forums (to any forums actually), and an electronics and Arduino n00b, so I apologize in advance for any accidental stupidity on my part  :D.

       I just got my Arduino a few weeks ago and planned to build an aquarium management system as my first real project. One key thing I wanted in the system was the ability to perform a 30% water change every week. To do this, I figured I'd get the Arduino to control a solenoid valve connected to my tap water supply and a pump to remove water from the aquarium and store in a reservoir. Considering both run off a wall socket at 240 V (I live in Asia), I initially assumed that relays were my best bet (I breadboarded the example circuit(http://www.arduino.cc/playground/uploads/Learning/relays.pdf) from the Arduino website and it worked fine).

         However, I recently discovered optocouplers and after some research, I found that they were comparable in price to my relays and draw less current. Also, if I understand them right, I would not need a snubber diode or a transistor. The fact that they are solid state makes them even more compelling.

       My question is, would it be advisable to stick with a relay circuit, or to use high voltage optocouplers instead. If so, are there any that can output 240V and 3A? Also, any futher explanations into their functionality and limitations would be great! Any advice or recommendations are greatly appreciated!

Many thanks,


or to use high voltage optocouplers instead

No an opto coupler is not the component to use, you want to use a Solid State Relay (SSR) there are plenty around that can handle that sort of voltage and current. They will have an opto coupler built in but that is not the name of the component you need.


Be very careful with this project. Any defects in your code sound like they could be quite serious. You'll likely come home at some point to dead fish in an empty aquarium or a flooded home (or both). Initially, perhaps limit your water supply to another reservoir so you can limit your exposure.

Sounds fun, but coding, especially if it has to be flawless, is tricky. Good luck.


... Be very careful with this project. Any defects in your code sound like they could be quite serious.

Think about "Limit Switches". Many serious systems such as motor-driven devices have switches arranged so that if the motion goes beyond an expected limit they shut off the power to the device.

You could add simple floats with thin string to "Microswitches" that are connected in series with your valve and pump power so that if the water level is below some limit (like 1/2) the pump is turned off and if the water level is above some limit the valve is turned off.  In "normal" operation the switches are never activated, only if some fault happened.

An example of this type of switch is here:

These have both "Normally Open" and "Normally Closed" connections, so it's easy to have one react to 'low' and one react to 'high'  . You need a little weight attached to each float so it will pull down as well as float up.

Of course, your Arduino is feeding them too, right??  :)   Turning their light on and off so they get some sleep??   Playing their favorite music??


I suspect it'll be cheaper to use relays with transistors and diodes than SSRs. Looking at these components for my project, I found each relays to be anywhere from 10 to 30 times cheaper than the SSR counterpart.


Thanks to everyone for the information and well wishes!

        @gorbs & @ grumpy_mike: Thanks for the info. After reading grumpy mike's post, I looked around for some SSR's that were in my price range. Sure enough, as gorbs said, the relays were a far cheaper option. I am therefore going to stick with them.

        @Terry King: Thanks for the suggestion. I will most certainly consider limit switches. Of course, the Arduino will be receiving feedback from level sensors placed in both the aquarium as well as the reservoir. I have yet to decide on a particular type of level sensor and was toying with the idea of building my own. Is that too ambitious? If so, the best bet so far seems to be this resistive tape:http://www.youtube.com/watch?feature=player_embedded&v=c3VJPi1TeSY. Any alternatives?

       As for the feeding and the lights, yes that is the plan. That's why I wanted to know more about the optocouplers. I now plan on making a bunch of relay circuits to control the lighting and feeding mechanisms, in addition to the pump and valve. I initially wanted to add dimming and moonlight effects, but I use flourescent bulbs in my tank. Not sure about the music though :D will have to check with the fish!


Mar 25, 2011, 09:48 am Last Edit: Mar 25, 2011, 10:21 am by Terry King Reason: 1
Here's a nice opto-isolated solution: 8 isolated relay channels for $25   DISCLAIMER: My Shop!

I've been looking for good relay and SSR solutions and these are the best I've found so far:

If I can't find a good low-cost Solid State Relay board I will build one soon....  (What Voltage/Current would you like to see??) How many channels on one board?

And there's this shield, but I personally don't like having 120 or 240 VAC right on top of my Arduino  ]:)

Go Up