I’m using an AutomationHat with a Raspberry Pi to control a device. The python library makes it easy to set the relays. Is there a way for me to ready a relays current position? Is it On or Off?
Bob
I’m using an AutomationHat with a Raspberry Pi to control a device. The python library makes it easy to set the relays. Is there a way for me to ready a relays current position? Is it On or Off?
Bob
I had the same question and wished you had gotten an answer! So… I tried using the same format as reading the analog ports and it works.
automationhat.relay.one.read()
You can try it in their relay.py demo: add this line thus:
while True:
automationhat.relay.one.toggle()
print(automationhat.relay.one.read())
if automationhat.is_automation_hat():
automationhat.relay.two.toggle()
automationhat.relay.three.toggle()
time.sleep(0.1)
Or better yet, add in this:
if automationhat.relay.one.read():
print("Relay on")
else:
print("Relay off")
Presumably it works for the other relays as well, I have a Mini, so I only have one relay to test.