Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

12v Solenoid

The IO Pi Plus is a 32 channel MCP23017 GPIO expander for the Raspberry Pi

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.

Tutorial 1 the blinking LED
Google Drive

20/12/2023

Posted by:
andrew

andrew Avatar

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 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

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.

Home

Shop

Learn

Forum

FAQ

Contact

0 item

Your cart is empty

Please browse our shop to order from the wide range of Raspberry Pi boards and accessories.

Subtotal:£0.00
View Basket Continue to Checkout