Easier way to hold a solenoid on pwm?
Posted: 07 Sep 2016, 13:25
I'm operating a number of solenoid valves to control irrigation.
The valves need 12v to operate but will then happily stay operated at 5v.
Only way I could think of was to use a rule with a one second timer to operate the valve and then switch to pwm at 512.
It works but also needs another gpio (4) operated by MQTT in order to generate an event (the switch input) to start the rule.
If I use the gpio the solenoid is connected to (2) it gets very confused. So here is the setup:
Rules:
On DummyIn#Switch=1 do
timerSet,1,1
gpio,2,1
endon
On DummyIn#Switch=0 do
pwm,2,0
endon
On Rules#Timer=1 do
pwm,2,512
endon
If I am being a bit thick and there is a much easier way to do this, please enlighten me!
The valves need 12v to operate but will then happily stay operated at 5v.
Only way I could think of was to use a rule with a one second timer to operate the valve and then switch to pwm at 512.
It works but also needs another gpio (4) operated by MQTT in order to generate an event (the switch input) to start the rule.
If I use the gpio the solenoid is connected to (2) it gets very confused. So here is the setup:
Rules:
On DummyIn#Switch=1 do
timerSet,1,1
gpio,2,1
endon
On DummyIn#Switch=0 do
pwm,2,0
endon
On Rules#Timer=1 do
pwm,2,512
endon
If I am being a bit thick and there is a much easier way to do this, please enlighten me!