Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5430

General discussion • GPIO pins on Raspberry Pi 5

$
0
0
Hi!
I’ve spent quite a lot of time doing research about how to use GPIO pins on my Raspberry Pi since it doesn’t work with RPi.GPIO as the older versions do.

I found two useful libraries: gpiod and gpiozero, but none of them work for me.

First, let’s dive into gpiod.
I copied and pasted the example code you can see in the PyPI website:

Code:

 import timefrom gpiod.line import Direction, ValueLINE = 5with gpiod.request_lines(    "/dev/gpiochip0",    consumer="blink-example",    config={        LINE: gpiod.LineSettings(            direction=Direction.OUTPUT, output_value=Value.ACTIVE        )    },) as request:    while True:        request.set_value(LINE, Value.ACTIVE)        time.sleep(1)        request.set_value(LINE, Value.INACTIVE)        time.sleep(1)
and I got this error message:

Code:

self._chip = _ext.Chip(path)FileNotFoundError: [Errno 2] No such file or directory 
Then, I changed chip0 to chip4 and still got the same message.

I tried other codes that included the function “get_line” and I always got the error message:

Code:

AttributeError: Chip object has no attribute ‘get_line’. Did you mean: ‘get_info’? 
I also tried to use this ‘get_info’ function, but I didn’t get to any point.

I looked in the forums and everyone seems to get ‘get_line’ working. I think it’s due to the new update. It says in the lint documentation that the new version has reworked the way of using lines.


About the gpiozero library, I tried to blink a LED using this code from the documentation:

Code:

 from gpiozero import LEDfrom time import sleepled = LED(17)while True:    led.on()    sleep(1)    led.off()    sleep(1)
and got the error message:

Code:

RuntimeError: Cannot determine SOC peripheral base address
I thought this has something to do with the wiring, but I triple checked it and I can say it’s alright.


Does anyone what could I try? I’m quite lost now (as you can tell) and it would be very helpful if someone could help me :)

Thank you in advance.

Statistics: Posted by Shunami — Sat Aug 31, 2024 10:42 pm



Viewing all articles
Browse latest Browse all 5430

Trending Articles