Hi, first time poster
I am wanting to create a relay circuit to turn on a 24v water solenoid using a raspberry pi 5, can anyone tell me if the attached circuit will work or if it needs any improvement please? I did not design the circuit so feel free to rip it apart.
As both sides of the opto-isolater are connected to the same supply, it is completely pointless.
So delete it, delete the 330Ω resistor as well and connect the PI output to the 1k resistor.
If you want an LED to show when it is on, connect an LED with a 1k resistor across the relay coil.
And learn to draw proper schematic diagrams, instead of this kiddy stuff.
A green LED has a forward voltage drop of 2.0-2.1V (in general), and the 817 isolator has a 1.2V drop. That is 3.2V to 3.3V in series, even without the 330 ohm resistor. It may be hard to drive both of those with just 3.3V from a micro and trigger the opto. Get rid of the green LED, or drive the opto and LED directly from the micro's pin (with proper current limiting resistor for each)