Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RASPI-GPIO Can't read from output #12

Open
BobSegrest opened this issue Feb 18, 2020 · 1 comment
Open

RASPI-GPIO Can't read from output #12

BobSegrest opened this issue Feb 18, 2020 · 1 comment

Comments

@BobSegrest
Copy link

I am using raspi-gpio in a device control application. I have a digital output line that drives a relay, but I also want to read the current state of the output line to drive a status indicator. If I define the pin as an output, raspi-gpio can't read the state of the pin. If I set it up as an input, I can't write to change the output.

My interface allow multiple connections, so I don't want to simply set a value and keep track of it for status display. I also need to be able to read the state to know that another operator has changed the value.

Is there a reason why I can't read an output value? Am I missing something in the interface that will allow me to do this?

Bob Segrest

@nebrius
Copy link
Owner

nebrius commented Feb 18, 2020

Hi @BobSegrest. You cannot read a value from an output, or write a value to an input. That's a fundamental limitation on how GPIO works, and there's nothing we can do about it.

DigitalOutput instances do have a value property on them, which contains a cached copy of the last value written to it from that instance, but it sounds like this won't work for your application

The way to do this, given your application constraints, is to wire a second GPIO pin configured as an input to your existing GPIO pin configured as an output. You can then read this new input pin and get the value "on the wire."

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants