Hi everyone, I have a problem setting up Pull-up / down resistors for GPIO buttons.
So, my buttons without any resistor work fine, but as there’s no resistors, i occasionally have unwanted button presses.
So I decided to put a pull resistor to any button. The problem is that when I actually push the buttons, sometimes they work, sometimes they don’t.
I’ve made a PCB like this:
POS ------ SW -------- GPIO ------- 10k res -------- NEG
POS ------ SW -------- GPIO ------- 10k res -------- NEG
POS ------ SW -------- GPIO ------- 10k res -------- NEG
Positive and negative are shared, and I tried both pull-up and pull-down just inverting positive and negative.
Any idea what i may have done wrong?
afaik Raspberry comes with both pullup and pulldown resistors built in, you only have to switch which of both should be active (in software)
Udo, thanks for the answer.
I’ve searched everywhere, but I didn’t find how to enable the internal resistors in openhabian. Any hints?
# Pull Up and Pull Down Resistors
When a GPIO pin is in input mode and not connected to 3.3 volts or ground, the pin is said to be **floating**, meaning that it has no fixed voltage level. That's no good for what you want, as the pin will randomly float between `HIGH` and `LOW`. You need to categorically know the state of the pin. So you need to fix the voltage level to `HIGH` or `LOW`, and then make it change **only** when (in the case of this guide) a button is pressed or a pair of wires are manually connected.
This can be done in two ways:
- A pull up circuit
Wire the GPIO pin to 3.3 volts through a large (10kΩ) resistor so that it always reads `HIGH`. Then we can short the pin to ground by closing the circuit so that the pin will go `LOW`.
![](images/pull_up.png)
- A pull down circuit
Wire the GPIO pin to ground through a large (10kΩ) resistor so that it always reads `LOW`. Then you can short the pin to 3.3 volts by closing the circuit so that it goes `HIGH`. When the circuit is closed, there is a lower resistance path to 3.3 volts, and therefore the pin will read `HIGH`.
![](images/pull_down.png)
Note: The 1kΩ R2 resistor is there in both circuits to give the GPIO pin a fail-safe protection, in case we mistakenly set the pin to be in OUTPUT mode.
This file has been truncated. show original
Afaik there is no option at all to do this in openHABian.
So, just for you to know, there IS a way to enable a raspberry’s internal pull up/down resistors in an openhabian system (actually any debian based system).
I may write a tutorial about it since there’s lack of information on the subject.
I’m a bit disappionted that your last reply just linked generic infos on pull up/down resistors that, if you read my first post, I already knew how they work. Luckily i’m stubborn and kept searching/studying.
Well, in fact the link is about how to enable internal pullup/pulldown resistors per pin, although you will need a python script. This sort of scripts is not part of openhabian (as far as I know).
I may have misunderstood your first posting
My apologies, as I’ve read the truncated file without opening the actual link.
Anyways I solved with wiringPI and a bash script.
rossko57
(Rossko57)
May 14, 2019, 12:42pm
8
Out of curiosity - are the pullups configured active in some way by default, then? Why didn’t your external pullups work as expected?
afaik by default there are some GPIs konfigured as pullup, some others as pulldown, so it depends on which GPI is used…