I am trying to control a SainSmart relay using a python3 script on radxa5. My code:
#!/usr/bin/python3
import OPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
channel = 36
GPIO.setup(channel, GPIO.OUT)
GPIO.output(channel, GPIO.HIGH)
if GPIO.input(channel) == 1:
relay_state = ‘relay off’
if GPIO.input(channel) == 0:
relay_state = ‘relay on’
print(relay_state)
time.sleep(10)
GPIO.output(channel, GPIO.LOW)
if GPIO.input(channel) == 1:
relay_state = ‘now relay off’
if GPIO.input(channel) == 0:
relay_state = ‘now relay on’
print(relay_state)
time.sleep(10)
GPIO.cleanup()
I also tried pins 16 and 18.
The code prints out “relay off” and “now relay on”, but when I test the relay with an ohm meter none of the contacts change at all, no matter which pair I test.
I have a bunch of raspberrys operating relays and they all work just fine.
This is confusing and I don’t have a clue what to do. It seems this should be simple. I run this script in Thonny and get no errors. Googled: radxa5 relay and got total of 9 hits and only one was radxa info, several were raspberry info.
Any gpio gurus around here?