5V Solenoid Valve & MOSFET (SOLVED!)

Hi everyone,

I am trying to activate and deactivate a 5 V solenoid valve with an arduino relied to an IRLZ44N. An LED should light on when the valve is activated.

The arduino sends a High PWM Signal for 3 seconds and then no signal for 3 seconds

void setup() {

pinMode(9, OUTPUT);

}

void loop() {

digitalWrite(9, HIGH);

delay(3000);

digitalWrite(9, LOW);

delay(3000);

}

The schematics is the following :

This circuit works well for the valve to let the flow go for 3 seconds and close but makes the opening/closing sound on and off. Also the LED does not light on.

Feel free to explain stuff even basic ones, I'm a beginner.

Thank you guys for your kindness and have a nice day !

No it doesn't and nor should it.

To get a PWM signal you have to use a analogWrite to the pin. What you are doing is setting a digital pin high or low, which is oddly what it needs to do.

Thanks for posting that.

What is this sound and where is it coming from? There is nothing in your code that makes a noise. If this is the noise from a PC, then it suggests that to me that some how your your wiring is not what you think but is causing a short circuit on power supply.

  • Make sure the LED is the correct way around.
  • Solenoids make noise.
  • Show us good images of your actual wiring.

Thank you for you answer, the sound comes from the solenoid itself and yep you are right for your PWM remark :+1:

Thank you for answering, you are right it does make a sound but just a small activation sound. When I use a usual 5V supply it does make the sound but here with the MOSFET I think it alternates between closing and opening which makes a big annoying noise. Here is the photo :

1 Like

Also when I lower the voltage of my power supply, it still makes that noise so I assume it is the MOSFET which keeps activating and desactivating really fast. What do you think ?

  • Confirm you are used an external 5v power supply (GND connected to Arduino GND); make sure this supply can supply the current the solenoid requires.

  • Solenoids make noise when they operate.

1 Like

Bud you just found my problem, with the arduino gnd connected to the supply gnd it works perfect. If you come by the south of France I'll get you a drink :slight_smile: Do you have any explanation why the two gnds need to be together ?

  • When an electron leaves the 5v power supply, it needs a rout back to that same power supply to complete its current path.
    We connect the Source of the MOSFET to the external power supply GND so the Drain current has a return path back to that external supply.

  • The MOSFET Gate, which is connected to the output of your Arduino pin, needs a reference to Arduino GND to be able to switch the MOSFET.
    The Gate to Source voltage needs the Arduino GND reference to turn ON/OFF the MOSFET.
    Hence the Source needs to be connected to the ARDUINO GND so as to provide this reference point.

  • Canada here, we are west of you, much rather have a loaf of French bread.

2 Likes

Sorry I had a tutorial on this but my internet service provider pulled the plug on the free web space they offered and took my whole site off line and didn't even offer a web redirection service. Tech support says every time they suggest this the CEO of the company says it will cost hundreds of thousand pounds to implement.
This file

Power_Supplies.zip (343.8 KB)

When un-compressed you can double click the .HTML file and it should load just that page into your default browser. Let me know if you have any problems with this. Of course none of the links off this page will work.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.