I am trying to connect a button to my raspberry pi 3 (model B). I want to do it via the sysfs approach. Here is a picture or my small circuit:
It cannot be simpler: the black wire is connected to a GROUND pin and to the breadboard. The white wire is connected to pin GPIO 2 and a 1K ohm resistance is attached to it. According to https://fr.pinout.xyz/pinout/pin3_gpio2#, this pin features a 1.8k Ohm pull-up resistance.
Now, because I am not using Raspbian but a Debian buster compiled for raspberry, the GPIO pin numbers are offset by 458 (see https://wiki.debian.org/RaspberryPi3).
I export the pin and set it as input:
echo '460' > /sys/class/gpio/export
echo 'in' > /sys/class/gpio/gpio460/direction
Now I read the value:
cat /sys/class/gpio/gpio460/value
This outputs '1', and this is normal since this pin is pulled-up by default.
My problem is the following: when I close the circuit, this still reads '1'. Can you explain this behaviour?
When using another pin as output, I can controll a LED so this does not come from the strange gpio pin numbering of this OS.