I am using this code to detect the rising and falling signal from a encoder using my Jetson Orin Nano. I have verified that if I connect line 105 to 3.3V on the board, the rising edge is detected by the code and if I connect it to zero volts, falling edge is detected by the code. Separately, I have verified that the encoder shows rising and falling voltage when tested with a multimeter. But when I connect the encoder to line 105, rising and falling signal is not detected. Why would that be the case? Any help will be appreciated. Thank you!
import gpiod
from gpiod.line import Edge
def watch_line_rising(chip_path, line_offset):
with gpiod.request_lines(
chip_path,
consumer="watch-line-rising",
config={line_offset: gpiod.LineSettings(edge_detection=Edge.BOTH)},
) as request:
print("Watching line for rising and falling edges...")
while True:
# Blocks until at least one event is available
events = request.read_edge_events()
if not events:
print("No events detected")
for event in events:
if event.event_type == Edge.RISING:
print(
"line: {} type: Rising event #{}".format(
event.line_offset, event.line_seqno
)
)
elif event.event_type == Edge.FALLING:
print(
"line: {} type: Falling event #{}".format(
event.line_offset, event.line_seqno
)
)
if __name__ == "__main__":
try:
watch_line_rising("/dev/gpiochip0", 105)
except OSError as ex:
print(ex, "\nCustomise the example configuration to suit your situation")