# I have a 110 VAC solenoid and want to know what kind of circuit i should build to control it from my microcontroller?

My solenoid is part of an old espresso machine, the circuit that detected low water level died and i can't replace it. I am adding a micro-controller to remotely turn it on and off and to control this water fill solenoid. I have the water detection taken care of, I built a control circuit that i can use to control a 12 V relay. My idea is to have the relay turn the solenoid on and off (the old circuit use a relay too). but I am just getting back into electronics and don't want damage the solenoid as a replacement would be very hard to obtain. Can anyone help me on what i should to to safely control this solenoid and protect both my micro-controller and the solenoid?

• can you measure the resistance of the solenoid coil? This would give you an idea how much current will flow. Commented Aug 25, 2013 at 17:31
• @miceuz - the solenoid is AC and the limiting factor will be the imedance at ac (i.e. inductance) not the dc resistance. Commented Aug 25, 2013 at 17:58
• about 400 Ohms, not sure how to measure impedance. I never worked with AC when I was younger so my knowledge of those functions on my multi-meter is lacking. I see some buttons labeled 'TRMS' looking for a manual now. Commented Aug 26, 2013 at 3:17

If the solenoid is a 110V AC type and your internal supply is also 110V AC then you can only damage the solenoid by having it switched-on for too long and it overheats.

Ask your self - should the solenoid activate only for a short period of time i.e. the time it takes to fill the tank. If so there is likely to be some form of top-float switch that disables the solenoid.

I would imagine there is a water-low and water-high level switch to activate the solenoid correctly so look into this and if so then no problem. However, if there is only a water low switch, the MCU may have to activate the solenoid for a fixed period of time then time out; the assumption being that the water adequately fills the tank but doesn't overfill.

If your MCU is a 5V type then you'll need a BJT to activate the relay: -

The diode is to prevent back-emfs damaging the BJT when it switches-off the relay (inductive load).

• I does only run momentarily, but to limit the current that runs through in case it has to be on for longer than normal (if the tank was very low after being drained it would need to run for over 5 minutes to fill the tank) what can i do to limit the current? I am guessing i would need a power resistor of some sort? Thanks for the quick reply, didn't even see that it came in so fast. Commented Aug 26, 2013 at 3:13
• @CaseyGregoire on the burnt-out circuit, how long did it control the solenoid for? It may not be a problem - checks to see how hot it gets - if it gets untouchable within say 1 minute you'll have to do something different but I suspect it may be OK. Commented Aug 26, 2013 at 9:54
• I only want to limit the current right off the bat because replacing the solenoid is most likely not possible, if it gets too hot, how do I decide what type of current limiting resistor to put on there? If anything I would like to know just to know even if I don't end up doing it. I am learning a lot here. Commented Aug 27, 2013 at 13:49
• @CaseyGregoire You need to do a test and measure the current flow with it powered on 110 Vac. You ought to leave it on and be testing the temperature as well. If it warms up a bit that's fine. If it gets too hot to touch that may not be OK. Knowing the current it takes allows us to put the right value resistor in series. Then retest with resistor - does it still work OK etc.. Commented Aug 27, 2013 at 14:51
• Everything worked out, but now from time to time when the solenoid switches off the micro controller resets. the solenoid is powered by the same source as the power supply on my micro controller, the power supply is a switching power supply. What can i do to stop that? Being that the solenoid is on the AC side of the circuit i am totally lost. Commented Dec 29, 2013 at 15:04