I'm attempting to use an Al-Zard DST-1R4P-N optocoupler (3.3v to 12v) to take the 3.3v signal from a Raspberry Pi and control a 12v solenoid. The image below represents how I'm attempting to wire it up, but it's not working.

Without any wire to terminal O1, the corresponding LEDs turn on and off in sync with the RPi pin going high and low, as expected. However, when connected as shown below, the LED on the output side stays lit all the time while the LED on the input side behaves as expected.

non-working wiring attempt, switching positive wire

Switching the cathode doesn't work either. In that arrangement, the output LED never turns on (instead of staying on all the time) and the solenoid still doesn't move.

enter image description here, switching negative wire

What am I doing wrong?

  • 1
    \$\begingroup\$ You have the wrong driver board. Get one with optos and relays \$\endgroup\$ Jun 27, 2020 at 23:01
  • \$\begingroup\$ Does this one fit the bill? amazon.com/… \$\endgroup\$
    – CragMonkey
    Jun 27, 2020 at 23:14
  • 1
    \$\begingroup\$ No . It is better to choose Relay Coil voltage same as solenoid (12V) amazon.com/dp/B07PT757NV/… \$\endgroup\$ Jun 27, 2020 at 23:18
  • 1
    \$\begingroup\$ It reduces risk of current noise EMI on the R Pi.. use twisted pairs to minimize crosstalk, But more important, sharing the same 3.3V defeats the purpose of opto isolator \$\endgroup\$ Jun 28, 2020 at 0:24
  • 1
    \$\begingroup\$ No use 3V with R to obtain same 5mA then 12V shared by Relay and solenoid or add FET if you know how \$\endgroup\$ Jun 28, 2020 at 1:02

1 Answer 1


enter image description here

You've connected the solenoid between the output and ground so it's just going to turn the output LED D1 on, on the plus side (so to speak) you've probably not (yet) ruined the board.

It won't be able to drive a solenoid of any significance, because it's just an optoisolator. You can look up the specifications of the optoisolators (those black 4-pin devices) but definitely they're not capable of driving most 12V solenoids.

You could add a MOSFET and a diode to make a driver, however. It doesn't even have to be a logic-level MOSFET with that board. For example, an IRF530 etc. with a 1N4004 diode.


simulate this circuit – Schematic created using CircuitLab

In this case, the solenoid is energized when the LED or power is OFF. If you want the opposite you can use a P-channel MOSFET with source to +12 and drain to the solenoid and diode.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.