def setup():
GPIO.setFunction(PinNumber, GPIO.OUT)
import webiopi
GPIO = webiopi.GPIO
RELAY1 = 18 (Change these numbers to the GPIO numbers of your relays)
RELAY2 = 22
def setup():
GPIO.setFunction(RELAY1, GPIO.OUT)
GPIO.setFunction(RELAY2, GPIO.OUT)
def destroy():
GPIO.digitalWrite(RELAY1, GPIO.LOW)
GPIO.digitalWrite(RELAY2, GPIO.LOW)
Digital write when changing high low
The tutorials online say to set the outputs low during the destroy. I suppose input would be safer in case you connect something while the Pi is running since the pin would be in a high-impedance state.
Kevin, you haven’t mentioned anything about your javascript yet. Are you still trying to change the gpio direction or states in there? Also, be sure to run in debug mode to catch any errors. To do so, enter this in your terminal sudo webiopi -d -c /etc/webiopi/config. Since you’ll be in debug mode, it would help to put some print statements in your script to verify it is running. Try adding this between your setup and destroy routines:
def loop():
print(“Relay 1 = {}”.format(GPIO.digitalRead(RELAY1)))
print(“Relay 2 = {}”.format(GPIO.digitalRead(RELAY2)))
print(“Relay 3 = {}”.format(GPIO.digitalRead(RELAY3)))
print(“Relay 4 = {}”.format(GPIO.digitalRead(RELAY4)))
print(“Relay 5 = {}”.format(GPIO.digitalRead(RELAY5)))
webiopi.sleep(1)
Lastly, try looking at your javascript console to see any errors that might pop up in your browser. In Chrome, press F12. It is possible that your HTML or javascript is causing problems too. Maybe if you post those files too we can find the cause of your troubles.