Access GPIO on linux side

Hi all,

I'm trying to get the gpio readings working on the linux side so I can later on work with DS18B20 temperature sensor.

When executing the example code

gpio5 = GPIO("/dev/gpiochip5", 5, "in")

value5 = int(gpio5.read())

print("GPIO5 = %d" % value5)

The following error occurred

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/periphery/gpio.py", line 539, in _open
    self._chip_fd = os.open(path, 0)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/gpiochip5'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/gpios.py", line 9, in <module>
    gpio5 = GPIO("/dev/gpiochip5", 5, "in")
  File "/usr/local/lib/python3.10/site-packages/periphery/gpio.py", line 496, in __init__
    self._open(path, line, direction, edge, bias, drive, inverted, label)
  File "/usr/local/lib/python3.10/site-packages/periphery/gpio.py", line 541, in _open
    raise GPIOError(e.errno, "Opening GPIO chip: " + e.strerror)
periphery.gpio.GPIOError: [Errno 2] Opening GPIO chip: No such file or directory

Any help would be appreciated!

Thanks

Hello @chen121617

Please stop the x8-devel container and try again :slight_smile:

use this instead

from periphery import GPIO
gpio5 = GPIO(163, "in")