0
\$\begingroup\$

I'm trying to use GPIO on my Beaglebone Black, but I'm running into some behavior I don't understand. I have two pins (gpios 27 and 61) configured to input with active_low set to 0. There is nothing connected to either pin (or any pin on the board for that matter), but one of the pins (gpio 61) is showing a value of 1 while gpio 27 shows a value of 0.

Can anyone explain why this is happening?

Here are the exact steps I took to get this result:

echo 27 > /sys/class/gpio/export
echo 61 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio27/direction
echo in > /sys/class/gpio/gpio61/direction
cat /sys/class/gpio/gpio27/value
0
cat /sys/class/gpio/gpio27/active_low
0
cat /sys/class/gpio/gpio61/value
1
cat /sys/class/gpio/gpio61/active_low
0
\$\endgroup\$
  • 5
    \$\begingroup\$ Without anything connected to a general purpose input the value is undefined or in other words floating and can take on the value of high or low. To combat this, normally pull-up or pull-down resistors are used either externally or internally. \$\endgroup\$ – DigitalNinja Apr 15 '16 at 22:57
  • \$\begingroup\$ DigitalNinja is correct. You should not rely on a CMOS input to have one value or the other when nothing is connected to it. \$\endgroup\$ – The Photon Apr 15 '16 at 23:01
  • 1
    \$\begingroup\$ Read Implications of Slow or Floating CMOS Inputs. \$\endgroup\$ – CL. Apr 16 '16 at 8:53
2
\$\begingroup\$

It's possible that one or both GPIOs are not floating. Those states that you see could be caused by the internal pullup/pulldown resisters.

Are you familiar with Debian's device tree overlays? That is what you would use to configure the I/O pins on the BBB. Besides input and output, you can configure pins for drive-strength and enable/disable pullup and pulldown resistors.

Have a look here for details: http://derekmolloy.ie/gpios-on-the-beaglebone-black-using-device-tree-overlays/

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.