Thanks to Joe Dohm, my water valve now works! I should have looked up the pins on the transistor. Here's the image Joe sent me from a Fairchild web page:
A different topic -- and my first practical use of my Rpi:
Several time a week my Frontier-supplied, Netgear-built DSL modem/wifi stops working. The Frontier complaint guy explained my problem as a "feature" rather than a failure. Apparently, there are a limited number of locally-assignable IP numbers and sometimes a number gets reused on a connected device that really hadn't gone away (merely quiet for a while). When the sleeping gadget wakes up the modem doesn't know what to do, so it stops working (forever?). Cycling power to the Netgear fixes things -- but it takes a few minutes and is irritating. Now, I admit that my immediate neighbors and I may sometimes have a dozen computers, phones and tablets connected -- all at once. But, so what?
The solution I dreamed up is as follows:
Leave the Rpi "on" 24/7 running the following BASH script (appended to the .profile file):
ps ax >/tmp/j
grep 'python ping.py' </tmp/j >/dev/null
if [ $? -ne 0 ] ; then
nohup python ping.py &
echo starting DSL test
I was planning to attach a 110V switch to the Rpi to cycle the modem power (see "DSL Fail" line above). But since I started letting this run, have had NO failures. No doubt my pinging is resource-piggy, but they brought it on themselves. A few lines of code added to the Netgear's software could fix the problem but the Telcos are probably saving bandwidth the way things are.
As mentioned in the code, I probably should increase the sleep time. Also, I chose to ping google.com because the site gave me quick echos. Very casual sampling, however.