Arduino controlling a heavy solenoid water valve So after burning up a couple Arduinos, I'm running out of ideas...

I am trying to power both a Solenoid valve and the Arduino(nano) with the same 12V-2amp power supply. I've tried it with both a relay breakout board, and via transistor switching, and both are giving me sporadic behavior for the Solenoid.

Early failures came from realizing that the solenoid water value was actually a coil (duh), and thus needed some kind of diode placed over its connections, so I'm assuming the back voltage spike is what fried the first two boards.

At first I added a small diode that helped but wasn't enough, so I beefed it up to a 3 amp "rectifier diode" 200PIV, which stopped the board frying.

Here is a link to the solenoid water valve. Not much to go on I'm afraid. 12V 0.02-0.8Mpa.   

The behavior that I'm seeing now, is that the solenoid will engage, but it won't disengage.

Do I need to add a Capacitor for the solenoid?  If so, any recommendations on sizing?



int relayPin = 2;

void setup() 
{ 
  pinMode(relayPin, OUTPUT);
  Serial.begin(115200);
} 


void loop() 
{ 
  Serial.println("starting");
  digitalWrite(relayPin, HIGH);
  delay(2000);
  digitalWrite(relayPin, LOW);
  delay(2000);
}
I have setup Arduino UNO and succeeded turning solenoid on when pot soil moisture dry, I was adding rain sensor when I mistakenly disvmcoonected the diode it fried my board, but atleast I had it working . I am using 24 volt normally closed solenoid , since I was monitoring over web I also had ethernet shield attached. And I was powering over ethernet using splitter and extracter.



The vin should only feed in 3.3 volt which you can get using stepdown buck converter , and use remains power to connect to solenoid. The transistor should be on the ground same as arduino nano the ground
The top became messy later