-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Relay open drain output (allow esp32 to drive 5v relay modules) #3920
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
Conversation
|
I have exactly the same (visually) relays in daily use and never experienced any issues with normal OUTPUT setting. |
|
@blazoncek do you power it from 5V or 3.3V? Both problems are fixed when powered with 5V and controlled by a 5V logic level. |
|
5V. |
blazoncek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've checked my old notes and there was a problem with one particular relay (which I attached to pre-release prototype of Dig-Uno) that didn't work. Since then Dig-Unos include level shifter for relays as should any hardware that mixes 3.3V logic with 5V logic.
That does not mean anything though. 😄
Question: does it make sense to combine both inverted/non-inverted with open_drain? If not, then it might be better to have a drop-down with 3 options: normal/inverted/open_drain, instead of two independent checkboxes? |
|
@Suxsem Very good ,I have a lot of those exact relays and they would only work if powered from 3.3V ( which as you |
That is a very good observation! |
@softhack007 @blazoncek I think they should be kept separate: all 4 combinations of inverted / open drain are valid. 3.3V relay modules should not use open drain but some may have an active-low logic and others may have active-high logic. 5V relays should use the open drain option with the pull up resistor but some of them uses an NPN transistor and others a PNP one so open-drain and inverted could be useful |
blazoncek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with changes.
wled00/data/settings_leds.htm
Outdated
| <div id="json" style="display:none;">JSON file: <input type="file" name="data" accept=".json"><button type="button" class="sml" onclick="uploadFile('/ir.json')">Upload</button><br></div> | ||
| <a href="https://kno.wled.ge/interfaces/infrared/" target="_blank">IR info</a><br> | ||
| Relay GPIO: <input type="number" min="-1" max="48" name="RL" onchange="UI()" class="xs"> Invert <input type="checkbox" name="RM"><span style="cursor: pointer;" onclick="off('RL')"> ✕</span><br> | ||
| Relay GPIO: <input type="number" min="-1" max="48" name="RL" onchange="UI()" class="xs"> Invert <input type="checkbox" name="RM"> Open drain <input type="checkbox" name="RO"><span style="cursor: pointer;" onclick="off('RL')"> ✕</span><br> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the X (span) next to input field and then I'll merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blazoncek sure, done!
|
Something might be you could also fix if possible is the multi-relay usermod |
This PR adds a new boolean option to the relay settings: open drain.
When select, relay pin mode is set to OUTPUT_OPEN_DRAIN instead of normal OUTPUT.
This allow driving 5v relay modules (cheap super common Arduino ones) just powering them with 5V and adding an external pull-up resistor between the module input pin and 5V, without risking the esp32 pins (that are not 5v-tolerant) and without additional level converters.
Fully tested