Skip to content
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

How to configure a relay with turn-high-low via GPIO? #1039

Closed
Yonsm opened this issue Jul 8, 2018 · 3 comments
Closed

How to configure a relay with turn-high-low via GPIO? #1039

Yonsm opened this issue Jul 8, 2018 · 3 comments
Labels
Milestone

Comments

@Yonsm
Copy link
Contributor

Yonsm commented Jul 8, 2018

Hi Xoseperez, I want to configure a relay that represents a high-low voltage at GPIO for both turn on/off action, that means I need toggle GPIO pin to high and then turn GPIO pin to low (about 0.3s delay) for both turn-on and turn-off action.

I found type(RELAY_TYPE_LATCHED)/delay_on/delay_off/pulse/pulse_ms params maybe is the right way, but I did not find relay config UI on web frontend. How can I get there, or how can config the relay on hardware.h.

Thank you and your help will be highly appreciated:)

@Yonsm
Copy link
Contributor Author

Yonsm commented Jul 8, 2018

I found that! The following configuration could be worked well:

    #define RELAY1_PIN          14
    #define RELAY1_RESET_PIN    14
    #define RELAY1_TYPE         RELAY_TYPE_LATCHED
    #define RELAY_LATCHING_PULSE 200

But the best code for me is (no reset_pin needed):

# relay.ino #117 add a new RELAY_TYPE_STRIKE
digitalWrite(_relays[id].pin, !pulse);
digitalWrite(_relays[id].pin, pulse);
nice_delay(RELAY_LATCHING_PULSE);
digitalWrite(_relays[id].pin, !pulse);

If you can support this relay mode, it's a good news:)

@xoseperez
Copy link
Owner

Both codes are equivalent. Instead of creating a new relay type I prefer to support single pin latched relays using the same type. I've added support for it in the dev branch. Configuration will be like this:

    #define RELAY1_PIN          14
    #define RELAY1_TYPE         RELAY_TYPE_LATCHED
    #define RELAY_LATCHING_PULSE 200

(no RELAY1_RESET_PIN)

@Yonsm
Copy link
Contributor Author

Yonsm commented Jul 14, 2018

Well done. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants