I'm using pchannel MOSFET for activating a CR02 valve like this one https://es.aliexpress.com/item/1938516987.html?spm=a219c.search0302.3.30.33c06d8djwoxkt&ws_ab_test=searchweb0_0,searchweb201602_0,searchweb201603_0,ppcSwitch_0&algo_pvid=42bb562b-db52-4060-8454-5a31a442a8ec&algo_expid=42bb562b-db52-4060-8454-5a31a442a8ec-4
This valve has 3 wires, one goes to +12V the other goes to GND and the remaning one is used to open/close the valve, if this wire is conected to +12V it opens the valve and if it's unconnected it closes the valve. I'm using the following circuit to operate this valve
VIN = +12V
QD = Arduino PIN
QDV = Valve control wire
It kind of works, I can open and close the valve but once every 6 or 7 times opening or closing it causes the arduino to reset and I don't know why. I'm using a 2A power supply and the specifications of the valve says it consumes 100mA so it should be enough, I'm also using a diode to protect from the spike of voltage when the motor is turned off, any idea what can be causing the problem?
Attached the schematic I'm using


At a guess electrical noise from the valve. If in doubt add capacitors across the power supply. Your schematic does not show the Arduino or how it is wired or powered, those are important details. A photo of your setup would help too.
Hi,
As @JCA34F has pointed out your valve needs two wires to open and close.
Once open or closed you can remove power and the valve will remain in that state.
Have you got the wires to the valve well away from the controller and its power supply?
It appears that electical noise on the 12V is getting into the controller.
What model controller are you using?
Can you please post a picture of your project so we can see your component layout?
Thanks.. Tom... 
Hi, the valve is CR03 sorry, the photo was just for reference, as I said in my original message the valve opens and closes as it should, the problem is not with the actual operation of the valve but just trying to understand why it resets the arduino 1/10th of the times. I will post some photos of my setup when I get home
It would be really useful to know the layout of your ground connections, as that would be my first guess at the source of your problem. Also possible you may need protection diodes.
Attaching the full schematic
It doesnt show the connections to the arduino or how the grounds are connected. I'm guessing there is nothing wrong with the "cabinet expander" unit.
johnerrington:
It doesnt show the connections to the arduino or how the grounds are connected. I'm guessing there is nothing wrong with the "cabinet expander" unit.
I'm attaching my custom arduino schematic together with an actual photo of my setup. BTW thanks for helping, I'm still learning electronics and PCB design!
markitus:
as I said in my original message the valve opens and closes as it should, the problem is not with the actual operation of the valve but just trying to understand why it resets the arduino 1/10th of the times.
It is because of the interference switching an inductive load causes. Sometimes it is enough to reset your Arduino. You have made the very common mistake of doing nothing to suppress this interference.
You need supply decoupling on the supply. I would use the last circuit on this page.
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html
Hi,
Sorry but you need to provide a schematic that shows your connections to components, not NET names all over the place.
Sorry but I looked at your schematic and went into almost Fritzy type shutdown.
That may be good for PCB manufacture, but not for troubleshooting.
- What power do you have connected to the control PCB to supply the LM1117?
- If you use USB 5V power for the controller board, does the problem still persist.
- If you put a decent GND connection between the PCBs and not rely on the connector ribbon for GND connection, does the problem persist?
- Have you got GND planes on your PCBs or at least nice wide GND tracks?
Thanks.. Tom... 
Problem solved I think Tom!
The schematic for the cabinet extender shows no connections for a power supply - so it must all be getting fed from the arduino board through the ribbon connector.
In which case the supply current is from J3 (arduino board) via ribbon cable, to the cabinet board (both 5V & 12V)
and ALL the current flows back via a single ground.
The OP NEEDS to break the ground connection and reconnect as a star; and most likely SHOULD use seperate supplies.
Markitus, for future refernce whan youre designing stuff like this (and full marks to you for your designs!) you need to lay out your supplies as for amplifiers; the supply goes to the output stage, and earlier (sensitive low current) stages are fed from that with suitable decoupling.
Try connecting your 12V supply to the cabinet board directly via the other expansion header.