Orange Pi Zero PA19 goes HIGH when reading input


Recommended Posts

Armbianmonitor:

When I try to read the input on PA19 immediately goes to "1" even though there is no voltage being sent to the pin.

 

Example:

#!/usr/local/bin/python

from pyA20.gpio import gpio
from pyA20.gpio import port

pin_to_circuit = port.PA19

gpio.init()

gpio.setcfg(pin_to_circuit, gpio.OUTPUT)
gpio.output(pin_to_circuit, 0)

gpio.setcfg(pin_to_circuit, gpio.INPUT)
print(gpio.input(pin_to_circuit))

I don't understand why this would put "1" with nothing even connected to the PA19 pin?


Are there some settings I need to change to get PA19 working as a normal GPIO pin?

Link to post
Share on other sites
Donate and support the project!

4 hours ago, David12412412 said:

I don't understand why this would put "1" with nothing even connected to the PA19 pin?

Pretty normal : PA19 is shared also as TWI1-SDA which is an I2C bus provided on header, and there are some PullUps resistors already present on the OPiZero board.

 

So, simply short PA19 to GND, you will see that your script will print "0".

 

Link to post
Share on other sites
14 hours ago, David12412412 said:

If i short PA19 to GND how will I detect any input on PA19 as it will always just show "0"?

I didn't say to short to GND permanently, but simply to check that the input is working fine as normal GPIO ...

 

4 hours ago, David12412412 said:

Is there any way to disable TWI1-SDA

It is already disabled by default, unless you load an I2C DT overlay ...

Link to post
Share on other sites
Posted (edited)

I'm still not really understanding how I go about using PA19 as a normal GPIO input port, so that I can check if an input has been received (such as from a push button).

 

Shorting PA19 to GND just means the voltage goes straight to GND and doesn't get detected as an INPUT.

 

I'm not sure if I'm asking my question in the wrong way?

For example if I have a push button from 3.3V to PA19 how can I detect a push on the button?

 

Circuit like this:

 

3.3V --------> Push Button ------->1k Resistor ------> PA19

 

Currently I cannot detect a push on this circuit because PA19 just shows "1" all the time for the input.

Edited by David12412412
Link to post
Share on other sites
On 8/2/2020 at 4:31 PM, David12412412 said:

3.3V --------> Push Button ------->1k Resistor ------> PA19

Error prone HW design with floating IO.
Proper design with fixed IO states:

VCC --------> Pullup Resistor ---|
GND --------> Push Button -------+------> PA19

The pullup is already in place.
Pressing the button will flip the IO from 1 to 0.

Link to post
Share on other sites
15 hours ago, Gabriel Bastos said:

Have u managed to PA19 work as input without reading HIGH level ?

What do you mean by "without reading HIGH level" ?

PA19 has a PullUp resistor, so by default it will be read as HIGH. To read it as LOW, it need to be shorted to GND as mentioned earlier in this thread ...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...