i connect to it using ssh.
but I’m struggling getting it to read/write to the gpio’s?
I’ve tried to use python to read a button state and use it to toggle a diode i have connected via a breadboard.
I downloaded the beaglebone-cookbook-code but alle the gpio examples seems outdated I can’t get any of them to work.
eg.
toggle1.py from beaglebone-cookbook-code/02sensors/gpiod
while True:
lines.set_values([0])
time.sleep(0.1)
lines.set_values([1])
time.sleep(0.1)
when i run this i get:
sudo python3 toggle1.py [sudo] password for beaglebone: Traceback (most recent call last): File “/home/beaglebone/beaglebone-cookbook-code/02sensors/gpiod/toggle1.py”, line 17, in chip = gpiod.Chip(LED_CHIP) File “/usr/lib/python3/dist-packages/gpiod/chip.py”, line 58, in init self._chip = _ext.Chip(path) ~~~~~~~~~^^^^^^ FileNotFoundError: [Errno 2] No such file or directory
I’ve also tried at chatgpt, claude and so on with no success..
I’ve searched for other libraries like adafruit but they all seems oudated?
I use the Bullseye IoT Image 2023-08-05 (it needs a little effort to remove the default password, but it’s got more free space and a nice easy flasher image). I copied the snippet (fixed the asymmetric quotes and indentation) and it works on that in Python 3.9.2 without sudo, with gpiod._version_ 1.6.2.
The error does mention the path. Perhaps try LED_CHIP = ”\dev\gpiochip1” ?,
I can’t say I’ve not installed something different with apt-get or pip though. But gpiod does work great for me in a venv, using the context manager approach instead. Incidentally I found the advice on GPIO’s PyPi page to set LINK_SYSTEM_LIBGPIOD=1 causes a compiler error.
Don’t forget a resistor in series with the LED - I didn’t bother with one at first, and I think I had to reflash after overheating the board (I’m relieved I didn’t cook it).
Thanks,
i guess i should reflash with something older then. This is running python 3.13 i think and didn’t check the gpiod version but seems it’s isn’t working with debian 13..
thanks for the heads up haha i have a resistor in place, I played with arduinos and rasberry pi’s before - but this seems difficult compared to those. I don’t get how it can be that tedious to receive a button input haha.