I try to build "irrigation controller" , the material which I used are: 1 relay model , raspberry pi model B , solenoid valve 24 VAC and AC-DC adapter (input 100-240v , output +24v ) I don't know which terminal of adapter(power supply) is negative and which is the positive !! It is not written on the wires but there something written on one of them (UL SPT-1 E179665 ... etc) Firstly, I connected valve with the adapter and it works (water passes) Now, I want to control it using my raspberry using python code, I already write it for ON:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
#This function turns the valve on and off in 10 sec. intervals.
while True:
GPIO.output(18, GPIO.HIGH)
print("GPIO HIGH (on)")
GPIO.cleanup()
The same thing for OFF (close solenoid) using GPIO.output(18, GPIO.LOW)
I used this connection like in the picture:
But when I put adapter in plug electrical , it will work !!! I don't need it to work else I run the python code which make it ON !!
I thought, the connections not correct, so many times I tried to manipulate the wires and exchange the connection in the relay... But Unfortunately nothing !!
Any way to help ?
while True: GPIO.output(18, GPIO.HIGH)
. Btw. SPT-1, SPT-2, etc. are just measures of wire and insulation thickness - it tells you how much current the wire can carry; it says nothing about polarities