Introduction: Controling a Solenoid Valve With an Arduino

Picture of Controling a Solenoid Valve With an Arduino

I need to take some vacation time and unfortunately, while I don't have kids, I have bonsais.

Like kids, these little critters need constant care and especially, water.

Each day.

Argh!

Why can't they drink beer/wine by themselves?

Anyways... Faced with no one close enough or willing enough to take care of them, I decided to use solenoid valves and an Arduino to create my own watering system.

At this point, it is easier and cheaper to buy an industry-made timer.

However, the final project will include watering based on a schedule and/or humidity in the earth, and a wireless logging system that will tell me while I'm away if everything is working as expected.

But let's start with the basic project, as this may be more than enough for the regular plant...

Step 1: Backgound Information

I will not talk (again) in details of the back EMF, why it is nasty and why you need a flywheel diode, as I already discussed that in another instructable here. You need that diode!

Solenoid valve : It is nothing more than a valve controlled by an electromagnet. It is, like relays and motors, an inductive load (aka an IC buster, go read on back EMF if it is not already done!). They usually come in two flavors : Normally Open or Normally Closed. Normally refers to when-there-is-no-current-in-the-solenoid. If you put pressurized water in a NC (Normally Closed) solenoid valve, water will be blocked. If you power the magnet with the expected current / voltage, the valve will open and the water will flow.

For NO (Normally Open), it is exactly the contrary.

Now, this is not the only variable. When current is flowing in the magnet, it creates heat. Most solenoid valves are not for continuous use. They have to rest and cool down between uses or they will fry. Read the small prints before committing to buying! And think about you project : are you watering a garden once or twice a day or are you filling an Olympic swimming pool with a garden hose?

MOSFET : In a nutshell, a MOSFET is like a light switch. You apply some voltage to the GATE terminal and the resistance between the DRAIN and the SOURCE will drop, allowing a lot of current to pass. Heat will be generated by the tiny (but real) internal resistance and you will need to dispose of it or risk melting your MOSFET. Also, by design, nothing being perfect, they are quite vulnerable to static electricity.

Here, we will use a N-Channel MOSFET, so don't be surprised if you see it connected between the solenoid and the ground.

Power supply : As you can see, I only use one 12V lead-acid battery in this project to power both the Arduino and the solenoid. Usually, this is not a good idea...

Let me explain :

Your Arduino, according to the official site, can deal with 7-20 volts and they recommend 7-12V, explaining that more than 12V can result in the board overheating. The reason is that the Arduino uses a linear voltage regulator that will get rid of the extra voltage by making some heat with it. If you give 7V 0.5A to a linear regulator like the LM7805, you get 5V and 2Vx0.5A= 1W of heat. If you give it 12.6V (typical voltage for a fully-charged lead-acid battery), you need to get rid of 3.8W of heat. And do you see any heat sink on the board? No? Actually, the board is the (very limited) heat sink.

This is the reason why I used a 85% efficient DC-DC buck converter that I had previously made. As it is quite another project to built a switching regulator, I will provide you with two clues. The first one (the inspiration for my own project) was a project published in Nuts and Volts in June 2008 by Jim Stewart. I modified their original design using information provided in the official datasheet of the LM2576. If you are in a rush to built one, use the schematic on page 11 (figure 22) and read everything, paying extra attention on the layout guidelines, stick to the recommended hardware and it will work. If you are not in a rush, I'll try to publish an instructable on it when I'm finished with this watering thing...

Step 2: Getting the Stuff...

Picture of Getting the Stuff...

This a simple project... The toughest part was not to find is the solenoid valves, but the adapters...

Hardware

Solenoid valve : I got these 12V / 0.4 A NC valves quite cheap on Ebay . They are working fine on domestic pressure. However, I should have pay a little bit more for a valve threaded directly for garden hoses. See the next point...

Adapters : As my solenoid valve had threads for 1/2" (while a normal garden hose is 3/4") I needed two adapters and a female/female adapter to connect two hoses together. I got them from a general hardware store, Believe it or not, together these are the most expensive pieces of this project!

What I was looking for (now I know, but I had to try many different adapters!) was two 3/4" MH x 3/4" MIP x 1/2" tapped FIP. I have no idea what it means, but this is what you are looking for and you need two of them! You will also need a 3/4" hose x 3/4" hose solid bass double female swivel adapter.

A power source : I use a 12V lead acid battery for this project to power both the Arduino and the solenoid. The unidentified piece of circuitry is a home made switching regulator. Go back to the last step, background information, if you don't know why it is there!.

MOSFET : I used a FQP50N06L for this project. Looking at the datasheet, it is probably overkill here as nothing more than 12V 0.5A will be used.On the positive side, I don't have to worry for thermal derating...

LED (Any color) : Any LED will do, it is mostly for debugging purpose.It will be on when the MOSFET is on, but it should be obvious if it is working as some water should be flowing...

Resistor : I used a simple 330 Ohm resistor that was lying on my bench. The idea is to make sure no more than 20 mA will flow through the LED. If you omit the LED, omit the resistor.

Diode : That is the one guy you should not omit. A normal 1N4007 was used.

Wires : To connect everything

Breadboard : To support everything

Software

Arduino IDE

Step 3: Assembling the Stuff

Picture of Assembling the Stuff

As I said previously, this is an easy built.

  1. Get grounded and discharge all static electricity you could have on you. I work on conductive foam and I always touch some part of my working bench mostly made of steel.
  2. Put your MOSFET in your breadboard. The TO-220 packaging may need a little push to get the leads in the breadboard.
  3. With the black part of the MOSFET (with the writing) facing you, the pin on the left is the GATE, the one in the middle is the DRAIN and the one on the right is the SOURCE.
  4. Connect your Arduino digital pin 2 to the GATE
  5. Connect the positive terminal of the 12V battery to the positive side of the solenoid
  6. Connect the negative terminal of the solenoid to the DRAIN
  7. Connect the SOURCE to the negative terminal of the battery

If you chose to use a LED :

  1. Stick the LED in the breadboard
  2. Stick the resistor in the breadboard
  3. Connect the resistor to your Arduino digital pin 10
  4. Connect the negative terminal of you LED to GND

Don't power up anything just yet! Did you forget something? Where is your diode???

It should be connected between the solenoid terminals, so that the little line on the diode is closest to the positive terminal of the solenoid. I decided to put the diode very close to the solenoid because :

  1. There are two very convenient little holes waiting for the diode in the crimps;
  2. I remember reading something about putting diodes as close as possible to the inductive load, but I don't remember the details. Any references anyone?

Step 4: A Simple Sketch

This is the "blink" sketch adapted for a MOSFET. Load the code in the Arduino IDE and read the comments. This is *not* rocket science.

Step 5: To Heat Sink or Not to Heat Sink... the Same Redundant Question...

After trying my circuit at 28 degrees Celcius in the sun, I registered a max temp for the MOSFET of 35 degrees and a max temp of 55 degrees Celcius for the solenoid valve after three cycles of one minute back to back, with only five seconds without power (using the sketch in the previous step). Considering I will only use this circuit to water the plants for a minute or two each day, there is no need for a heat sink.

Now, if your idea is to transform your backyard into a swamp to have a pet gator, I strongly suggest :

  1. Find another pet (Gators hate Canadian winter);
  2. Check the temp both of your MOSFET and your solenoid;.
  3. Remember that temperature increase is usually not linear;
  4. Install a big fat heat sink and a fan to be on the safe side;

Step 6: Scale It Up!

My final design will involve 3 different zones, each controlled by a MOSFET. Even if you have tons of pressure in your hoses or very short ones, it is not a good thing to use all the solenoids at the same time. For one thing, if you are running this on batteries like me, the less juice you pull from your battery, the closest you will be to that expected Holy Grail of the Amp/Hour number written on the battery. Yep, manufacturers don't tell you this, but batteries are not linear : the more you ask from them, the less they will give you in the end!

To scale this to more zones, just use one digital pin per MOSFET. If you need more, it is possible, but I'm not there yet (I have a backyard, not a golf course!).

Talking of batteries. as the Arduino is drawing 42 mA 24/7 and my solenoid is drawing 400 mA for 2 minutes each day, my fully charged 12V 9 Amp/Hour should last more than our Montreal summer...

With a 9 Amp/Hour fully charged, you have access to 108 000 mW/h of energy (hum, probably less, as you don't want to deep discharge (and kill) you battery). However, considering the 4.8W for 2 minutes (hence 160 mW/h in average) plus the 0,247 W/h needed by the Arduino powered by a 85% efficient switching power supply, you have a consumption of 407 mW/h...

  • With one solenoid. it means 265 days of use;
  • With two solenoids, it means 190 days of use;
  • With three solenoids, it means 148 days of use.

The cool thing is that I just found a nice little 12V, 12 Amp/h battery... Should give me more than a summer even with three zones! So I'm not in such a hurry to design my next project; a solar charger!

Step 7: In Conclusion...

This is a work in progress ; the final version including a three zones and a much nicer sketch should be posted soon. But for now, you do have the tools and the knowledge to create your own watering system!

Comments

fmarquis (author)2017-11-11

Good to know this is working now! I plan to revisit this project with an esp32.

ChandramouliS1 (author)2017-10-19

Hello, like you said, finding the right kind of adapters seems to be the hardest part for me right now. I have been testing out the 12 V DC solenoid valve I purchased online, I bought the adapters as shown in the picture below. For now, I connected a hose pipe directly to the input side adapter. But water leaks between the brass and stainless steel adapters on the input side. The output side is fine. I did not think I had to mimic your adapters exactly as you use them since I bought a hose pipe that fits well with the brass adapter I bought, and plan to use a hose clamp to keep it tightly in place. Any idea why I am seeing the water leak? Could it be because my Solenoid valve (looks low on quality)? Could you explain why you needed the female-female adapter? Is that on the input side or the output side?

KitR2 (author)ChandramouliS12017-11-10

it could either be the valve or one of the hoses not clamping on tightly enough.

be sure to screw them on quite tight to make sure that there's less chance. the value and fittings I got don't leak at all.

(and yep I do got it mounted on a used pringles can, it was just the right height for where I wanted the value)

ChandramouliS1 (author)KitR22017-11-11

I had to do some trial and error with various attachments and hose diameters. In the end I used clamps on any leaky joints and have my system up and running. It is all hooked up to a raspberry pi and waters multiple plants on a timed basis ( I can also turn it on remotely when I need to and for however long I need it to run.) Saved me when I had to travel recently. All my plants are alive and well.

fmarquis (author)ChandramouliS12017-10-27

I recently learned that hose threads could be of two types, one being tapered and not the other. I think your leak is coming from trying to mix the two.

ChandramouliS1 (author)fmarquis2017-11-11

I had to do some trial and error with various attachments and hose diameters. In the end I used clamps on any leaky joints and have my system up and running. It is all hooked up to a raspberry pi and waters multiple plants on a timed basis ( I can also turn it on remotely when I need to and for however long I need it to run.) Thanks for your help.

KitR2 made it! (author)2017-11-10

okay so this isn't a sprinkler system. but it it's using a solenoid vale and a air pump in a configuration to be controlled by an Arduino so I think that counts.

this version the Arduino isn't on the circuit as I'm still working out a cool control scheme using that. still it can power it and both the pump and the value are setup to be controlled by it. and it's all running off a 12 1amp wall wart that's been alligator clipped on the back. it's a pressurized beverage dispenser. unlike all those basic diy videos that can only work with non carbonated drinks this one can keep pressure in. I've also attached a crude drawing of the circuit. it works quite well.

KitR2 (author)KitR22017-11-10

wish I could go and edit my original posts as I noticed I left something out. while not big figure it's worth mentioning. what I used for my 12v to 5v convertor is a cheap car charger that I liberated from it's case the two soldiered on leads at the front are so that I got an easy place to stick the alligator clips from the power supply and have 12v in for both the vale and the power adapter.

MuneerM2 (author)2017-11-07

Sir, could you please send me the circuit diagram to my mail 'muneermohammadali@gmail.com as I am working on a similar project. Thank you :-)

raj100784 (author)2017-02-25

Could you please share the circuit diagram with me "g.rajksingh@gmail.com". I would really appreciate it. I am planning to work on a similar project and need this.

minimeccanica (author)2017-01-21

I'm running a similar project (early stage) but would like to use latching solenoid to limit wiring in my garden. Has anyone any idea where can I find a latching 1/2-3/4" plastic valve for a reasonable price? Some Chinese supplier?

OleP1 made it! (author)2016-09-14

Thank you, made it and looks like everything working. I first did the wiring wrong, so the colour coding on my wires is not correct.

Im also planning to use this to water my plants.

This is the script I made so far, not receieved everything so have not got it tested yet. https://github.com/oleost/WaterSystemArduino

mehmetsukru (author)2016-08-03

I cannot see the connections, do you have lage view or circuit scale?

EricH125 (author)2016-03-14

Can i get your email? I was brainstorming a way to manage multiple water supply valves in ground ( under mobile homes) using either arduino or pi to control valve then adding leak detection and excess flow reporting to activate valve but also needed wireless or remote activation to close the normally open valve with one with a home connected but normally closed otherwise. Im wanting to build a community project to help small operators connect to each valve through a GUI and open or close remotely and to receive flow meter ticks to compile and track usage.

Ideas welcome.

Eric

fmarquis (author)EricH1252016-05-16

Look around, already been done. There is a user in India who did pretty much the same for a small community where his parents live. I just don't remember the link...

EricH125 (author)fmarquis2016-05-16

I'll keep searching - if you find it please let me know - very interested.

nonderbe (author)2016-02-17

Hi,

Being a newbie, I accidently bought the wrong MOSFET as it turns out. I bought an FQP27P06, which is according to its datasheet a P Channel MOSFET, whereas you are using an N Channel MOSFET.

I will try to make this project work anyway, with the tools I now have at hand. After sitting at my desk with my hands in my hair for a considerable amount of time, I now understand that the main operational difference is that N Channel MOSFETs let current flow from DRAIN to SOURCE, while P Channel MOSFETs let the current flow in the opposite direction, from SOURCE to DRAIN.

I am about to find out whether my last remaining MOSFET will be fried when I will switch the cables that connect to DRAIN and SOURCE on the breadboard.

If you don't see me following this up with YEEHAAA or something equivalent, could you please explain why that didn't work, and maybe how anybody with a P channel MOSFET at hand could make this work?

nonderbe (author)nonderbe2016-03-15

OK, I was able to buy an N-channel MOSFET: IRFZ44N

http://www.irf.com/product-info/datasheets/data/ir...

However, the circuit doesn't work, and I don't understand why...

I checked the MOSFET, it should be fully functional, according to the tests with my multimeter.

The solenoid seems fine: when i connect it directly to the battery leads, I can distinctly hear the valve.

The arduino is programmed correctly as far as I can tell. When I test the voltage between digital pin2 and GND, I get 0v and 5v with 5 second intervals.

When I connect everything... nothing happens.

Ideas, anybody? Are the specs of the MOSFET up to the task?

fmarquis (author)nonderbe2016-05-16

Do you have a pulldown resistor on the gate?

nonderbe (author)nonderbe2016-03-15

The specifications of my parts:

solenoid valve: 12v dc 8.5w // 12v ac 4.4va
diode: IN4006
battery: 12v 2.0AH/20hr
MOSFET: IRFZ44N

nonderbe (author)nonderbe2016-02-17

Hmm, it doesn't seem to work. Bugger :(

nonderbe (author)nonderbe2016-05-10

The problem was that I was working with two power sources. Apparently, the rule there is to always connect both grounds to get stable voltages. If you mix two power sources you will get a voltage that floats somewhere in between, which, well, makes you waste a lot of time wondering where it all goes wrong. :-)

JosephC128 (author)2016-03-18

I'm trying to decide between using an N-channel MOSFET or a NPN Darlington transistor to drive 12V 500mA to a solenoid. I already have 2N7000 N-channel MOSFET at home, but I looking at the datasheet, I don't think it's right for the job. Do you recommend the FQP50N06L over using a TIP120 Darlington?

fmarquis (author)JosephC1282016-05-16

Some people hate mosfet because they fell like their vulnerability to static electricity is a huge issue. To tell you the truth, I started working with mosfet before transistors, and I never had a circuit fried because of that issue. Thermal failure is the usual culprit. And when working at logic level, it is easier to work with mosfets than transistors, for me at least!

JosephC128 (author)2016-03-18

Also, if the device only needs to run for 2 minutes daily, you can save yourself a lot of juice by putting the Arduino in deep sleep mode. You can use either an external timer or the internal watchdog timer (which unfortunately has short intervals) to wake it up. Check out Kevin Darrah's channel on YouTube. He does an excellent series on low power Arduino.

fmarquis (author)JosephC1282016-05-16

Absolutely true. This was more designed as a proof-of-concept. If you want this thing to run forever from a small solar panel and a few supercaps, that's the way to go!

i.saralynn (author)2015-06-19

Is it possible to use a voltage regulator like the LM7805 to convert the 12v to 5v then route the 5v to the arduino and 12v to the solenoid? I'm trying to do a similar project where 2 analog sensors trigger 2 solenoids, but using a 12v wall power supply. This is the schematic, I haven't gotten it to work yet though properly, the sensors keep frying :/ Not sure if the problem is my arduino code, or the schematic/wiring.

Ruben GeradM (author)i.saralynn2016-02-29

I think you shoud try using a simple voltage divider circuit.

fmarquis (author)i.saralynn2015-06-19

... I was re-reading your comment and I will quickly add one thing : if your sensors are frying, it is probably because you need to limit the current going through them. What it you sensor? Do you have a part number or a datasheet?

i.saralynn (author)fmarquis2015-06-21

Thank you so much for your detailed comments! And happy anniversary :) My circuit *seems* to be working now (thought I don't leave it plugged in for an extended time), I'm pretty sure my problem is the code now. (I've attached the code that works with just 1 sensor to 1 solenoid. I can't figure out how to add in the 2nd sensor to the 2nd solenoid... Someone suggested using a class or array, but I couldn't figure that out.) The voltage regulator has a heat sink and it doesn't seem to be getting to warm now. This is the power supply I am using: https://www.adafruit.com/products/352 . When I measure with my volt meter it does seem to stay around 12v. The sensor is Pulse Sensor Amped: http://pulsesensor.com/pages/open-hardware . Attached is the schematic. It says "Current consumption = ~4mA at 5V". Instead of having the Solenoids connected to pins A2 and A3, they are now connected to digital pins 11 and 5. Thanks again for the help!

fmarquis (author)i.saralynn2015-06-21

Good Morning from Sarlat, France. I'll be moving to Toulouse in a few minutes, so I don't have much time... Telegraphic style then :

Power supply : ok, should work very well.

Sensor : I looked at the schematics, shouldn't be drawing a lot of current, you are right.

Software : I never really played with interrupts. That's my next step. If you want to make some kind of multitasking as you have two sensors working at the same time, that will make things quite complicated using interrupts. I've seen "multitasking" libraries on the official Arduino site.

If it is not top secret, could you describe exactly what your device should do?

i.saralynn (author)fmarquis2015-06-22

Good morning! The project is 2 heart beat sensors trigger 2 solenoids (door lock actuators) that make drumsticks move. So each drumstick taps to a different person's pulse. A friend wrote up a different sketch that doesn't use interrupts, but it doesn't work well, the drumsticks tap a few times, then stop tapping. I'll attach that.

fmarquis (author)i.saralynn2015-06-22

Sorry, something went wrong. this is the second part of my reply.

So, I was saying that you could use a universal timer like the millis to do all the coordination and avoid stopping the processor. Create a function that measure and average your HR, send that value to the drumstick as a frequency for the beat and resample the subject's HR.

Is it helping or does that just made you more confused? If so, I'm sorry about it and I'll try to find a better example.

i.saralynn (author)fmarquis2015-06-25

Hi yes, interesting... I understand the idea, but have no idea how to write the code myself. Maybe I'll just use 2 arduinos..... Could my schematic power 2 arduinos?

fmarquis (author)i.saralynn2015-06-25

Yes, it is possible with your power supply to power a second copy of your circuit. However, to be on the safe side, you should have two voltage regulators too, as LM7805 are usually 1 amp max and even if you don't get to that, you will need to dissipate more heat. If you keep only one LM, check the temperature and be careful not to burn yourself as I myself did in the past.

Again, a small modification could be to add 2 or 3 25v electrolytic capacitors in parallel close to your power supply. Better to have 2 small ones than a big one as two will decrease the total ESR and together, they will act as a good electron reservoir, should your mechanical parts drain too much when working at the same time. This way your voltage will stay 12v for your LM and you don't risk a reset. You could also double the capacitor after the LM with an identical one in parallel, especially if your Arduino behave strangely.

Doubling the hardware is not the most elegant way, but it is a good way, and will get you a working prototype probably faster than the software learning curve will permit. Being myself more hardware than software oriented, I truly understand what you are going through.

Good luck!

i.saralynn (author)fmarquis2015-06-25

Thank you so much for all the help. I really appreciate all of your responses!

fmarquis (author)i.saralynn2015-06-22

I just arrived in Toulouse and did some thinking about your problem. As you are not designing a medical device, you can probably use a few tricks to make your life easier. First, most healthy human beings will have a heart rate between 60 (very, very well trained athletes) and 200 per minute (if you are young and running for your life). Now, unless you have a medical condition, (atrial fibrillation, SVT, etc) you heart rate will not suddenly change. While acceleration is a little bit quicker, going back to a normal, resting beat takes much longer. You can use this phenomenon to modify your sketch. For example, once initialized, the Arduino measure HR on sensor one for 5 seconds, averaging the HR. Then, it goes to sensor two, doing the same thing. Each 30 sec or so, the Arduino can update the response and lock it in a variable used to control the drumsticks.

To do so, you can use a state machine and you should absolutely avoid using anything that can delay or stop your Arduino, like

fmarquis (author)i.saralynn2015-06-19

Hi!

The short answer to you question is yes.

Remember that the voltage regulator will dissipate a lot of heat to drop the voltage from 12v to 5v and that without a heat sink, you can't aimed a dissipating more that 2.5W. Even with a heat sink, going more than 7W is risking an internal shutdown. Look at your datasheet.

Also, unless you have a regulated 12v, the usual "wall wart" will output more than 12v, making everything worse. Check it under load to be sure.

The better option is to use a switching power supply to go from 12v to 5v. Easy to build, I can send you schematics. You will need around 5 different components. However, if your board is already designed, you may be interested in this :

http://www.digikey.ca/product-detail/en/R-78E5.0-1.0/945-2201-ND/4930585

It is a 5V DC-DC converter which is a drop-in replacement for a LM7805.

Know, to answer the question about why you are frying the microcontroller. I quickly looked at your schematic as I'm on vacation in Europe and tonight is my anniversary ;) but I don't see anything critically wrong. I should point out a few points though :

1- You are not supposed to bypass the internal regulator of your Arduino. However, I clearly see why you are doing it. You can use an switching regulator or a liner one with a heat sink to drop from 12v to 7v and then use the internal one that is supposed to protect your Arduino.

Maybe you are frying the chip because you have transients spiking because of the something in your circuit or your power supply. You could try a 5.5v zener diode between +5V and GND a crude surge protector.

2) The same comment applies to the analog pins connected to the sensors. Could they experience spikes? If so, the same strategy could be tried, with a 5.5v zener between Analog pins and GND.
Remember that the analog pins are quite sensible to voltages over 5v.

3) The Arduino is quite limited in its capacity to sink current. I don't remember by heart, but I think it is 200mA, including what is used by the Arduino itself. That means if your sensors, connected to 5v can deliver a lot of current, you will fry your chip.

Also, that means your solenoids GND should not be connected directly to the GNDs on the Arduino, but to a common GND.

Try this, and if you have more question, I will gladly answer, providing I know the answer and I have an internet connection!

Good luck!

Bima Sakti (author)2014-11-09

besides using MOSFET FQP50N06L, is there any other series MOSFET that can be used ?

Please Reply and Help

Thanks :)

fmarquis (author)Bima Sakti2014-11-10

You have many options. First, you have to consider the current rating of your MOSFET. Choose one that can support considerably more current than your solenoid will need. This way, it will stay cooler. Try to use one with very little resistance, so heating will be less of a problem. Finally, find one with a "logic" level gate voltage, meaning it will be fully "on" at 5v. This final point is important to reduce heat production. If it gets too hot, use a heatsink or a bigger MOSFET.

You will need to find the datasheets of your possible candidates to get these numbers, but they are always on the datasheets.

Another option could be a transistor. The principles are the same : must support more current than your solenoid valve needs and be fully on with 5v. Be sure to add a resistor between the pin and the base of the transistor to limit the current to 20mA.

VamshiK7 (author)fmarquis2016-01-06

This was amazing actually I'm in search of same project and this one is really good , I'm gonna work on this for my house hold gardening purpose well before that I have a query if I want to water my plants fr a span of 10 to 15mins as U said I need to use a heat sink , is there any alternative to run the project without heat sink if possible how ??? If not what nd which type of heat sink I need to use pls give me the reference links. And pls explain me once again about the total power supply given to the board if i want to give the power to board through my home i.e 230v by using a step down transformer to let down the voltage to 5v how I can connect that to the board and the solenoid.

pls clear my doubts asap waiting fr ua. Reply :)

VijetaB (author)2015-11-23

Hi,

Great Project. I'm wondering if the same principle works while controlling compressed air. What solenoid would you recommend for controlling pressure unto 100PSI from and 18 CFM air tank?

fmarquis (author)VijetaB2015-11-30

Good morning! I was out of the country, giving two talks in Mexico and believe it or not, the internet connection was down. Now, to answer your question, I never tried to use this system with pressurized air, but it should work as long as your solenoid is capable of dealing with the expected pressure of your system. The solenoid I used are for drinking water only (to gas, no chemicals) as are most solenoid available cheaply on the net. Be certain that you will be able to drive your solenoid with your power supply as compressed air = industrial and most of the time industrial = 24v. Don't drive the arduino from 24v, use a DC-DC converter to drop 24v to 7v and connect that to DC in of the arduino. If you feel confident, use a 24v to 5v and power directly on the 5v pin but this is not recommended as you could fry your arduino.

AnishaA1 (author)2015-09-05

hello,

this is an excellent project,really appreciate the effort.

can you please give me the exact code that you send to the arduino for this to work?

also is it possible to control the intermediate states of the valve; i.e half open etc?

fmarquis (author)AnishaA12015-09-07

Thanks.

As this is a solenoid valve, it is only fully ON or fully OFF because an electro-magnet is opening the valve. Strategies like PWM will not work. I'm using this valve with a garden hose : the faucet is used to control the pressure and by controlling the time the valve is kept open, I can control the amount of water.

As to control the valve, this is the code :

/*

MOSFET FQP50N06L - For BonsaiDuino

This sketch will blink a LED and at the same time, use the MOSFET to open a 12V solenoid.

Arduino D10 : To LED (Through 330 Ohm Resistor)
Arduino D02 : To MOSFET Gate

Created by Francois Marquis for the Intructable "Controling a solenoid valve with an Arduino"
This code is public domain, you can use it and play with it

*/

int ledPin = 10; // Connect the pin to Arduino pin 10
int mosfetPin = 2; // Connect the MOSFeT Gate (first pin on the left, when writing on the chip is facing you) to Arduino pin 2

void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(mosfetPin, OUTPUT);
}

void loop()
{
digitalWrite(ledPin, HIGH);
digitalWrite(mosfetPin, HIGH);
delay(60000); // Will turn both the LED and the MOSFET on for 60s, it gives you plenty of time to see if water is flowing as expected!
digitalWrite(ledPin, LOW);
digitalWrite(mosfetPin, LOW);
delay(5000); // Will shut down everything for 5s and restart.
}

About This Instructable

99,291views

129favorites

License:

Bio: A crazy mix between a physician and a mad scientist...
More by fmarquis:Laser Cut Stand for DIY LED Seed StarterInstalling a heater on a VESA compatible articulated LCD screen supportBlack Garlic - Probably the Easiest Way to Make It at Home!
Add instructable to: