Designing a switching system for solenoids on Raspberry Pi
Typically you want to use a NPN driver circuit, using a 2n3904 or similar. The NPN drives your p channel mosfet or PNP driver circuit. Logic will be inverted but it will work it the max 16mA output of the RPi.







simulate this circuit &ndash; Schematic created using CircuitLab

Schematic shown has a 6mA load on the RPi output. Resize the resistors as needed. Left Q2 could be a BJT PNP or a P-Channel Mosfet. Right Q5 is NPN and N-Channel Mosfet. Size for your solenoid power.