High Voltage Solenoid Interface with MCU

This mini article provides a small circuit idea to interface a 12V or 24V DC Solenoid (or relay) with a 3.3 or 5V microcontroller’s i/o pins.

24v solenoid/relay interface with microcontroller


JLCPCB Prototype: $2 for 10 pcs PCBs, 48 Hours Quick Turn

China’s Largest PCB Prototype Enterprise, 300,000+ Customers & 10,000+ Online Orders Per Day

Get quote online easily: https://jlcpcb.com/ quote

Facing problem with your embedded, electronics or robotics project? We are here to help!
Post a help request.


Avinash Gupta is solely focused on free and high quality tutorial to make learning embedded system fun !

More Posts - Website

Follow Me:
FacebookLinkedInGoogle Plus

Line Following Robot Kit
Industrial Counter

5 thoughts on “High Voltage Solenoid Interface with MCU

  • By Uttam Dutta - Reply

    Very nice application , probably – can be used in door lock or timer controlled water spraying for garden, but difficult part — how or where to get the solenoid or miniature valves !
    Uttam Dutta

    • By sudarshan - Reply

      Hi Uttam Dutta,
      you can get miniature valves from automobile spares shop. all LPG powered cars(not sure about petrol or diesel) have solenoid valves to control the flow of gas.

      regarding solenoid you can get a piece of steel and copper wires for a motor repair shop and wind it on the steel and you will have a good solenoid

    • By Robin - Reply

      Go to any washing machine repair shop, you can buy an old but working water solenoid from them. If you ask them nicely they will even tell you where you can buy new ones from. A new washing machine solenoid costs around 250 to 300 ruppees.

  • By priya - Reply

    can u please send me the code regarding this project..

  • By Robert - Reply

    I am going to use PWM to control my solenoid valve and was just wondering if my waveform will be distorted in any way by the transistor?
    Or should I just stick to using a motor driver instead?

Leave a Reply

Your email address will not be published. Required fields are marked *

six + = 8

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>