Wiring the Solenoid

The solenoid and MOSFET are also easy to wire up.

The 5V USB line on the Feather and one lead from the solenoid are connected to a 5V rail on the breadboard. The other solenoid lead is connected to the MOSFET drain pin. The source pin is connected to ground. When enough voltage is applied to the gate, it will complete the circuit and the solenoid will activate. The gate is controlled by GPIO 13. An optional 10K ohm resistor pulls the gate to ground. This mitigates coupling capacitance and ensures the solenoid will not activate if the gate is allowed to float.

A 1N4001 or 1N4004 snubber diode is placed as close as possible to the solenoid leads with the cathode on the positive side. The diode protects the circuit. When power is cut to the solenoid, the electromagnetic field collapses and can generate a substantial flyback voltage which could damage the MOSFET or other components. The snubber diode dissipates this current.

This guide was first published on Oct 16, 2019. It was last updated on Oct 16, 2019. This page (Wiring the Solenoid) was last updated on Oct 31, 2019.