Search code examples
raspberry-pigpiocircuit

GPIO values always default to logic 1, is that normal?


I've got a Raspberry Pi Zero W v1.1 set up today and I've been trying GPIO's. Got them (I'll refer to GPIO #3) to output between 3.3v to 0.05v on command using echo 0 > /sys/class/gpio/gpio3/value with direction OUT and got them to read in logic 1 to 0 by connecting pin #7 (GPIO #3) to a ground (will replace with a sensor later on) with direction IN.

My question is: Would you consider this normal that the Raspberry Pi defaults to logic 1 as soon as you enable the export? echo 3 > /sys/class/gpio/export

Can somebody elaborate on why this is? Also, why is this exactly the opposite of this guy's scenario: Reading a sysfs GPIO input pin (direction as "in") always print a fixed value (0)

Kthx


Solution

  • You said there is nothing connected to the pin, yet you read value=1. This is due to internal bias on the input which is weak and can be over-driven by an external circuit if you were to connect something to the pin. The internal bias simply is a large (~1M ohm) resistor to the VCC, so you are reading this bias. Try connecting a 1K ohm resistor from the pin to ground and read it again. It should read value=0 as you were initially expecting.