Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

12v Solenoid

1 Views - Created 20/12/2023

20/12/2023

Posted by:
sunilvb

sunilvb Avatar

I am a noob, trying to operate a 12v Solenoid with Rpi4 + IOPiPlus + 12v Relay. Took the Blinking LED sample code and used it as-is for the 12v Solenoid. Quickly figured out I will need help. Appreciate any and all guidance.

https://www.abelectronics.co.uk/kb/article/17/io-pi-plus-tutorial-1-the-blinking-led
https://drive.google.com/file/d/1YkHNToP7ESybP93u-obfoX_v4uEuNsTa/view?usp=sharing

20/12/2023

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hi

Your relay board will need to be wired up differently to use it for switching a solenoid.

The solenoid needs to be connected to a relay output. Connect the 12V+ to the middle of the three screw terminals and the solenoid to the next terminal. The ground wire for the solenoid needs to be connected to the 12V ground on the power supply. If the solenoid activates when the power is switched on you may need to move the solenoid 12V+ to the screw terminal on the other end of the 3-pin connector nearest the edge of the PCB.

The ground on the IO Pi Plus needs to connect to the DC- terminal on the long row of connectors. Pin 1 on the IO Pi Plus connects to the IN1 terminal. This allows the IO Pi Plus to control the relay through the optocoupler on the relay board.

If your relay board runs on 12V you will need to connect the DC+ terminal to your 12V power supply. If it is the 5V version connect DC+ to the 5V pin on the IO Pi Plus. If you are not sure which version you have you can check the voltage rating of the relays. The 5V version should have a relay code of SRD-05VDV-SL-C. The 12V version should have a relay code of SRD-12VDV-SL-C.

The image below should help explain this better.

forum image

Another option for controlling your solenoid is to use a transistor, resistor and diode. We have a tutorial for this on our website at https://www.abelectronics.co.uk/kb/article/1052/driving-relays-or-higher-loads-with-the-io-pi-plus.

20/12/2023

Posted by:
sunilvb

sunilvb Avatar

Hi Andrew,

Thank you for the guidance. I wired everything up as you suggested and ran the code again but nothing happened. I noticed that there was no power coming into the relay (SRD-12VDV-SL-C). So, I connected the DC- terminal from the relay to 12V GND of the power supply as well. I then saw the green power LED lit up on the relay.

Nevertheless, running the code sample did nothing again. Wondering if there is anything else missing. Appreciate your help!!

FYI, I am able to operate 8 solenoids using the GPIOs directly from the RPi4 + 12V, 8 Channel Relays + 12V Power Supply (I connected the DC- terminal from the relays to 12V GND of the power supply in this setup as well).

https://drive.google.com/file/d/12h1ktJULWANacww9hiiZozW08buLrff8/view?usp=sharing

20/12/2023

Posted by:
andrew

andrew Avatar

Location:
United Kingdom

andrew Twitter  andrew Website  

Hi

Sorry I missed the ground wire between the power supply and the relay board.

If you connect the IN1 pin on the relay board to the 5V pin on the IO Pi Plus does it activate the relay and the solenoid?

Try measuring the voltage output on the IO Pi Plus pin 1 output without the relay board connected. If it does not go high or low when you activate it in your code then that will narrow the problem down to the IO Pi or the code and not the wiring to the relay board.

If you don't get any output from the Bus 2 pin 1 on the IO Pi Plus try using Bus 1 instead. In your original diagram if the relay was activated it would have fed 12V directly into the pin on the IO Pi Plus which may have damaged the chip. If that is the case then hopefully the other IO chip will still work.

20/12/2023

Posted by:
sunilvb

sunilvb Avatar

Never mind. It was a wiring issues. I was able to fix it and works well now. Thanks again!!

Sign in to post your reply

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.