I am currently undergoing a project with the aim to achieve a specific flow rate. I have decided on using a solenoid and needle valve (set manually) in series to achieve this flow. I have calculated the solenoid valve needs to be turned off 10 seconds and on for one second. I am new to Arduino and have been watching some Youtube tutorials using a relay and solenoid valve and somewhat understand the connections and process.
This is the valve that meets the criteria of my project. Am I able to connect a 24V DC to an Arduino circuit and control this?
Any help on how the circuit may look/components would be greatly appreciated.
I appreciate the response and help, I am just unsure as to what components I would require instead due to the 24V solenoid. For example, would the resistors etc. not change?
You can use a logical MOSFET transistor that handles a little bit more than 24 volts, and the current into the coil. Connect +24 to the coil +. Coil - to the MOSFET, MOSFET to the GND common for controller and 24 volt supply. Transistor gate to the controller output via a resistor, some 100 - 1k,
The coil wattage is only 6.8W, about 28mA, so a 2N2222 NPN transistor would probably work fine, don't forget the diode in parallel with the coil, cathode, (end with band) toward V+ to protect the transistor.
So I can use a 24V solenoid with Arduino and it will work fine as long as the other components work with it?
The schematic provided is that simple? I assume the coil is what, the solenoid valve?
Thank you for your assistance! It is highly appreciated, I am a beginner with circuits and valves but have been given this section as part of my project.
mh95ncl:
The schematic provided is that simple? I assume the coil is what, the solenoid valve?
Yes and yes. It's indeed that simple.
In fact a transistor of sorts (more common is a MOSFET - but for this low current a BJT like the 2N2222 or BC547 will do just fine) is much more suited to switch DC than a relay. Especially for higher currents/voltages which are very hard to switch with a relay (due to arcing), yet no problem with a transistor.
Just be sure you get the transistor leads right, looking at the bottom with the flat side up, normal is E, B, C (Emitter, Base, Collector) but some part numbers have it reversed. Search for the datasheet for the one you have.
I did not know that an Arduino was capable of handling more than 5V. Is it? I was discussing with my friend using an Arduino but he thinks it can't. I'm sure I have seen it being used with higher voltages. This may be a problem as the solenoid valve is a 24V DC.
mh95ncl:
I did not know that an Arduino was capable of handling more than 5V. Is it? I was discussing with my friend using an Arduino but he thinks it can't. I'm sure I have seen it being used with higher voltages. This may be a problem as the solenoid valve is a 24V DC.
Again thank you for your time.
The entire purpose of the circuit in reply #4, is to isolate the high voltage and current of the solenoid, from the 5V digital circuitry of the Arduino. Notice that the diagram specifies 24V.
These questions may sound stupid but like I said I am a beginner in circuits. How is it isolated? So the Arduino will require another separate 5V supply?
mh95ncl:
So the Arduino will require another separate 5V supply?
The Arduino always requires a regulated 5 V supply. Do not be tempted to try and feed it via "Vin" or the "Barrel jack" if you are actually using it for a "real world" application as the on-board regulator is not up to the job.
If you have - say 24 V - then a readily available switchmode "buck" regulator (eBay if you can wait) is appropriate to feed in to the "5V" pin. Otherwise a readily available USB "phone charger" is most convenient.
It is the transistor which separates the 24 V part from the 5 V part. Just make sure the ground for both supplies as reliably connected together and to the transistor.
You need a diode that is capable of passing at least the same amount of current as the coil is passing.
I saw 28mA discussed, that doesn't need much diode.
1N4004 is rated for 1A, so that would be plenty.
It lets the coil-created current dissipate in the coil when the transistor turns off.
Thank you. How do I know which components will be sufficient for this circuit? For example, how do I select a transistor. What type and voltage, current etc?
Also, the resistor from the Arduino, how do I select that?
Resistor: you need to limit the current from the Arduino pin. Vbe across the transistor is typically 0.7V (like a diode).
So, (5V - 0.7)/.025A (25mA) = 172 ohm, so a 180 ohm, 220, 250 ohm resistor will work fine.
mh95ncl:
Thank you. How do I know which components will be sufficient for this circuit? For example, how do I select a transistor. What type and voltage, current etc?
Also, the resistor from the Arduino, how do I select that?
User JCA34F put the component part numbers right in the diagram for you
JCA34F:
The coil wattage is only 6.8W, about 28mA, so a 2N2222 NPN transistor would probably work fine, don't forget the diode in parallel with the coil, cathode, (end with band) toward V+ to protect the transistor.
In terms of how this isolates ... think of the transistor sort of like a 'one way' relay. So on the diagram above, when B is energized with 5v, then C and E become connected to each other. So the 24v flows through the transistor, but only from C to E ... it does not flow through B.
If you took your meter and measured vdc across the transistor pins when the Arduino pin is energized, you would find 5v between B and E ... and you would find 24v between C and E.
25 mA is actually a bit much for an Arduino pin; best stay under 20 mA (datasheet recommended limit for an ATmega328p microcontroller; that upper limit may differ for other chips).
For a BJT you normally want a base current of 5-10% of the collector current, this to drive the transistor in saturation. In your case this collector current is 28 mA (the current of the coil), so base current should be 1.4-2.8 mA. I'd aim for 2.5-3 mA, the high end of that range as you're well below the 20 mA limit of the pin. A 1k5 resistor or thereabouts would do.
Now you also see one reason we like MOSFETs so much: they don't need current to flow through the gate, like a BJT does for the base. A simple BJT is OK for currents under 500 mA (then you're at 25 times amplification with a 20 mA base current!), over that you need a Darlington or, better, a MOSFET. For anything over 200 mA I'd take a MOSFET, below that whatever I find in my parts box (which includes a stack of BC547 NPN tansistors).