RPI.GPIO Pull-Up an...
 
Notifications
Clear all

[Solved] RPI.GPIO Pull-Up and Down


pkrahmer
(@pkrahmer)
Active Member
Joined: 2 weeks ago
Posts: 17
Topic starter  

Is there a specific reason why we cannot choose pin behaviour (free floating, pull-up, pull-down) for the two RPI.GPIO modules state and edge detection?

As they are only resistors, a wrong setting should not be able to brick something - at least not more as an accidential setting of the pin as GPIO output.

My specific scenario is: I've connected an opto-coupler module pulling the input to ground (via an on-board resistor) or let it float. I have to pull-up the input to make it work.

I want to avoid to fumble-in an additional physical resistor. So I've added a custom option for these input modules in my fork (defaulting to "floating" -> no change in default behaviour). Wondering whether the change is desired in main repo and I should do PR?


Quote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 6 years ago
Posts: 570
 
Posted by: @pkrahmer

Is there a specific reason why we cannot choose pin behaviour

No specific reason, I just haven't had a use for it. I'd welcome the addition, so long as the default option is what it currently does, so that there are no changes to users currently using these inputs. Thanks!

Mycodo Developer


ReplyQuote
pkrahmer
(@pkrahmer)
Active Member
Joined: 2 weeks ago
Posts: 17
Topic starter  

@kylegabriel

Cool, please have a look: https://github.com/kizniche/Mycodo/pull/935

Did some testing, also with defaults. Seems okay for me but lend me a pair of eyes for a code review, please.


ReplyQuote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 6 years ago
Posts: 570
 

Looks good. Merged! Thanks for the code additions.

Mycodo Developer


ReplyQuote