this post was submitted on 15 Oct 2025
9 points (90.9% liked)

diyelectronics

530 readers
8 users here now

founded 3 years ago
MODERATORS
 

I am trying to get a solenoid water valve to work with my raspberrypi pico and python. The system works with a LED but when I swap the led with the valve, add the diode and switch the power to 5v (external, not pico), the valve does not open. When I use a voltage meter, I can measure a resistance for a short moment when connect to the valve so I suppose it functions?

Below is the schematics (the triangle thing represents the solenoid valve). The diode is a 1N4007

The valve has a pulse with of 30ms at 5V so I programmed a PWM to open 30ms and then 200ms (I tried to follow this tutorial: https://learn.adafruit.com/use-dc-stepper-servo-motor-solenoid-rp2040-pico/solenoids )

Am I missing something?

all 15 comments
sorted by: hot top controversial new old
[–] RubberElectrons@lemmy.world 3 points 1 week ago* (last edited 1 week ago)

30ms is quite fast.

[–] GorGor@startrek.website 1 points 1 week ago (1 children)

Some of those water solenoids are made to run off 24VAC. What is the model of solenoid you are using, and have you confirmed operation without the pi?

[–] Vincentvd@lemmy.ml 1 points 1 week ago (1 children)
[–] GorGor@startrek.website 1 points 1 week ago* (last edited 1 week ago) (1 children)

Interesting. I've never seen a solenoid want an hbridge to drive it.

Give it what it asks for

https://arduinoyard.com/l298n-motor-driver-with-arduino/

Edit Forgot this was for a pico. Same basic ideas.

https://microdigisoft.com/control-dc-motor-using-l298n-raspberry-pi-pico-micropython/

[–] Vincentvd@lemmy.ml 2 points 6 days ago (1 children)

Thanks for the help btw. Together with other comments I will look into this. I thought it was a nice and easy project to start with😅

[–] GorGor@startrek.website 2 points 6 days ago

They never go how we think they will. Learning along the way is what's fun, for me at least. Please update when you get there or get stuck again.

[–] residentoflaniakea@discuss.tchncs.de 1 points 1 week ago (1 children)

Could you clarify a few things? The circle symbol is meant to represent the voltage supply? Is it connected correctly? When you say solenoid, you mean an electromagnet, right? If so, why does it require that specific pulse with? You say you swapped out the LED for the coil, was the LED tested with MOSFET and diode in place? Does the solenoid engage when you take the connection off the RP2040 and drive it high directly? How did you ascertain the functioning of the solenoid by means of measuring resistance?

[–] Vincentvd@lemmy.ml 1 points 1 week ago (1 children)

But if I connect it to the 5v power supply directly it will destroy the coil according to the specs https://www.tinytronics.nl/en/mechanics-and-actuators/solenoids/solenoid-valves/solenoid-valve-latching-5v-brass-g1-2

No, the diode was not tested with the led but with the voltage meter on diode mode, I verified the diode works (I even flipped the diode for testing).

I tested the solenoid by setting the multimeter to resistance and connect the testing probes to the solenoid

[–] residentoflaniakea@discuss.tchncs.de 1 points 1 week ago (1 children)

So the setup you have is not going to work. Even if you managed to get the valve to engage, it'll require a negative voltage pulse to disengage according to the specs you linked above.

[–] Vincentvd@lemmy.ml 1 points 6 days ago (1 children)

Thanks, i see what you mean now. Would another valve like the one below work with my setup? My power adapter supports 12v so that is no problem.

https://www.kiwi-electronics.com/en/plastic-water-solenoid-valve-12v-1-2quot-nominal-2624?search=valve

[–] residentoflaniakea@discuss.tchncs.de 1 points 6 days ago (2 children)

The idea with the first valve is to drive it with an H-bridge. This allows for reversing polarity and is commonly used with motors to allow for spinning in two directions. This requires 4 MOSFETs. I'm not sure what type of MOSFET you are using but if you can find a simple dc motor to test this setup you can verify that it works with the one you have before you extend the circuit to an H-brigde configuration. This would be cheaper than buying another valve. You'd need two GPIO pins and careful design to not short circuiting the H-bridge.

[–] Vincentvd@lemmy.ml 1 points 6 days ago (1 children)

Thanks for the help btw 🙂

Of course. Let me know how you're getting on.

[–] Vincentvd@lemmy.ml 1 points 6 days ago

I see. I have 4 valves for the system I want to make. I don't think my prototype board is large enough for 4 h bridges. Either I buy the other valves or some of these I suppose. https://www.tinytronics.nl/en/mechanics-and-actuators/motor-controllers-and-drivers/dc-motor-controllers-and-drivers/l298n-bipolar-stepper-motor-and-dc-motor-motor-controller