Using optocopler when driving solenoids - a must?

I'm using either 200mA 12V solenoids or 480mA 12V solenoids with arduino. I was wandering if it is enoigh using a logic level mosfet driver circuit or better to add optocoupler?

If there is no reason for the 12V supply to be isolated then an optocoupler is not needed

how can I know if there is a reason or not for the 12V supply to be isolated?

here is two schematics for the two options:

It's very much dependant on your overall system design an saftey consideraions

In what cases those optocouplers can be avoided? or in what cases they are must be used?

Using an optocoupler is not mandatory in any case.

Avoid common GND to the Arduino when the solenoid is far from the Arduino or when the solenoid draws very large current.

1 Like

far is more then lets say 1 - 2 meters?

Optocouplers are needed if various grounds cannot be connected. Otherwise, usually not.

What IS important is that the voltage spikes and dips caused by the high current draw of the solenoid do not get into the Arduino power supply.

why that various ground can't be connected?

One example would be connecting equipment powered by different branches of the AC power line.

In some of those cases, "ground loops" are formed if you try to connect the grounds, which can damage or destroy equipment.

The decision to use an optocoupler is made on a case by case basis.

If the potential difference between the two grounds would cause dangerous currents to flow, then they should not be connected

In my case all the solenoids and the arduino will be powered from the same AC outlet but the solenoids itself will be placed 2 - 5 meters away from the arduino (using 2-5 meter 22awg silicone wires)

Then you don't need optocouplers

Why did you think an optocoupler might be needed, and where did you think to place it?

22 AWG wire is rated for 0.92 Ampere power transmission, so consider using heavier wire.

the solenoids I linked too are rated for 200mA and 580mA - both below the 0.92A of th 22 awg wires. Still needed to consider heavier wire?

No.

When the Mosfet goes short between the Gate and Drain the 12V supply will run to your Arduino pin and destroy your Arduino.

The Opto will prevent this.

This did not happen when I used the circuit that use no optocoupler