Using a Solenoid (12V) with a relay and Photon

Hi guys!
I have a problem with my automatic water system. I’m using the following elements:

Since the Photon’s output is max 5V I need to be able to give the valve what it needs thru the relay. The relay is connected +(VIN), -(GND) and for testing purposes the S pin is connected to the D7. And I have tested it to just turn on and off every second. That part works.

The power cables to the 9V battery is connected to the solenoid and is hooked into Common and NC - Normally closed.

My problem is that the battery is getting way to hot. Would an IN4001 solve my problem here? I’m a beginner so go easy on me :slight_smile:

PS! I tried including a video showing the relay working as it should…

Check the amperage rating of your battery vs what you’re actually pulling from your solenoid.


It look like you have both the battery and the solenoid coil connected to common and NC, is that what you have? When the relay is not energized (i.e. common connected to NC), you’re just short circuiting your battery, no wonder it gets hot! That’s definitely not what you want to do. You should have one side of the battery wired directly to one side of the solenoid coil. The other side of the battery should be connected to the common of the relay, and the other side of the coil should be connected to the NO terminal of the relay. The 1N4001 which is suggested in the information about the valve is a flyback diode that should be connected across the two terminals of the solenoid.


In the image above, the fixed end of the switch would be your common terminal on the relay, and the open end of the switch would be the NO terminal of the relay.


As @Ric said above, the wring on the solenoid side is not right. You should have one power lead going directly from the battery to solenoid while the other power lead is switched by the relay.

And as @Mjones said, your solenoid draws 240mA at 9V according to the datasheet you posted. The 9V battery is spec’d to have a total of about 400mAh at 100mA current draw. They don’t spec that battery for 240mA of current but I would think you might get one hour of total “on” time at most.

So you need to rewire the solenoid side and get a decent power supply.


Thanks Ric! I will try this and get back to you!

Thank you too Bko! I will rewire as soon as I get back home!

1 Like


I am using that exact same valve for my watering project. If you want a design for a Photon carrier board or the software, check out my project document here.




Thanks Chipmc! That’s awsome! I have also put together my own sensor station, where I will measure humidity, soil moist, temperature, light, rain etc. And with your code for the web hooks I can use our own service in Norway( which provide the same services. :smile:

Hi Ric! It worked like a charm! Thank you so much!

PS! The buttons attached is for something else :wink:

quite nice of you to do all this work, thank you!

1 Like