-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NewRelayDriver should allow for creating inverted relay #648
Comments
Seems like a good idea. A PR that added this would be gladly accepted. |
@deadprogram just a ping to remind that I have done a PR for this. (just in case this issue was overlooked) |
func (l *RelayDriver) On() (err error) {
if err = l.connection.DigitalWrite(l.Pin(), 1); err != nil {
return
}
if l.Inverted {
l.high = false
} else {
l.high = true
}
return
} I notice you are still writing 1 to DigitalWriter (Outside the Inverted if logic) in Driver.On - this is hardly helping. Most of the relays close NO-C on LOW ! Wouldn't it help to check Inverted before you DigitalWrite 1. |
As @kneerunjun noted, Would you accept a PR that takes the |
Yes, please, and thanks! |
Great :-) |
@stuartleeks Thank for this. I saw this email yesterday and was going to start updating this today; Then I noticed you already submitted a pull request :) Not sure how I missed that it still writes 1 instead of 0. Our code that uses this functionality is currently still doing the old manual if-check, so we never actually caught this bug in our code. Good job catching it! |
Thanks @andrewebdev. I was working on a home project with my raspberry pi and thought I'd misunderstood gobot or mis-wired my relay. After checking my circuits and code I started digging in to the gobot code and found what @kneerunjun described which led me to this issue. Hopefully we can get the PR merged and the change released soon, and then I can use the |
Seems to be fixed. Otherwise please try "WithPinActiveLow()", available on "dev" branch. |
Currently
.On()
sets the relay state to high, and.Off()
sets the relay state to low.We have realays boards in one of our projects that are actually inverted.
This causes us to do things in the code like
relayDriver.On()
when we want it switched off, and of course it leads to some confusion down the line.It may be a good idea for NewRelayDriver to allow for this use case?
The text was updated successfully, but these errors were encountered: