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?
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).