1 1
David12412412

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?

Share this post


Link to post
Share on other sites
Want Armbian t-shirt or a cup?

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".

 

Share this post


Link to post
Share on other sites

Is there any way to disable TWI1-SDA, so that PA19 just acts as a normal GPIO pin?  (so that I can read inputs normally as i would on another GPIO pin)

Share this post


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 ...

Share this post


Link to post
Share on other sites
(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

Share this post


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.

Share this post


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...
1 1