Hej Folks!
I am relatively new to RP, playing around for about 4 weeks now with the RP5. Half a year of experience with Python. So maybe my question is obvious to solve for others, but i have done quite some research / testing and not found any explanation / solution so hopefully some of you can enlighten me.
I am pretty lost on using the GPIO Pins - which i generally love to do.
First getting into GPIO was more difficult then i thought, but after some time i figured out that apparently RPi.GPIO is not working anymore on RP5 as they should do - so people advise to use GPIOZero instead, right? But GPIOZero still needs to have any pin factory as a base for communication. After some struggling i got my first GPIO Scripts working, but then started using virtual environments for some reasons.
And i have not figured out how to access GPIO from venv - and more confusingly the more i tested the less i understand how GPIOZero actually works on RP5.
Using GPIOZero without venv with a stepperMotor works perfectly fine:Execution & Output:It really fascinates me that there seems no gpiozero.pin_factory but its working.
Now the same with venv:Ok, i see, i dont have any pin factory, so i install some (have installed each alone and still did not work):And another problem - basically everytime i use RPi.GPIO, i get the same error:
RuntimeError: Cannot determine SOC peripheral base address
Full response:And lastly pip list:I really dont understand what the problem here. It should not be a rights problem, as the user is the same. But what else? Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Thanks for any help!
I am relatively new to RP, playing around for about 4 weeks now with the RP5. Half a year of experience with Python. So maybe my question is obvious to solve for others, but i have done quite some research / testing and not found any explanation / solution so hopefully some of you can enlighten me.
I am pretty lost on using the GPIO Pins - which i generally love to do.
First getting into GPIO was more difficult then i thought, but after some time i figured out that apparently RPi.GPIO is not working anymore on RP5 as they should do - so people advise to use GPIOZero instead, right? But GPIOZero still needs to have any pin factory as a base for communication. After some struggling i got my first GPIO Scripts working, but then started using virtual environments for some reasons.
And i have not figured out how to access GPIO from venv - and more confusingly the more i tested the less i understand how GPIOZero actually works on RP5.
Using GPIOZero without venv with a stepperMotor works perfectly fine:
Code:
from gpiozero import OutputDevice, Devicefrom DRV8825 import DRV8825print("from gpiozero import OutputDevice, Device")print("Device.pin_factory: "+str(Device.pin_factory))print("OutputDevice.pin_factory: "+str(OutputDevice.pin_factory))try: Motor = DRV8825(dir_pin=24, step_pin=18, enable_pin=4, mode_pins=(21, 22, 27)) Motor.SetMicroStep('hardward', 'fullstep') Motor.TurnStep(Dir="forward", steps=500, stepdelay=0.002) Motor.Stop()except Exception as e: print ("\nMotor stop") Motor.Stop() print(e)
Code:
myuser@raspberrypi-assistent:~/python/motor $ python motor-test-neu.py from gpiozero import OutputDevice, DeviceDevice.pin_factory: NoneOutputDevice.pin_factory: NoneControl mode:hardwardforwardturn step:500
Now the same with venv:
Code:
(gunicorn) user@raspberrypi-assistent:~/python/motor $ python motor-test-neu.py from gpiozero import OutputDevice, DeviceDevice.pin_factory: NoneOutputDevice.pin_factory: None/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/devices.py:295: PinFactoryFallback: Falling back from lgpio: module 'lgpio' has no attribute 'SET_BIAS_DISABLE' warnings.warn(/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/devices.py:295: PinFactoryFallback: Falling back from rpigpio: No module named 'RPi' warnings.warn(/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/devices.py:295: PinFactoryFallback: Falling back from pigpio: No module named 'pigpio' warnings.warn(/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/devices.py:295: PinFactoryFallback: Falling back from native: unable to open /dev/gpiomem or /dev/mem; upgrade your kernel or run as root warnings.warn(Motor stopTraceback (most recent call last): File "/home/user/python/motor/motor-test-neu.py", line 10, in <module> Motor = DRV8825(dir_pin=24, step_pin=18, enable_pin=4, mode_pins=(21, 22, 27)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/python/motor/DRV8825.py", line 16, in __init__ self.dir_pin = OutputDevice(dir_pin) ^^^^^^^^^^^^^^^^^^^^^ File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/devices.py", line 103, in __call__ self = super().__call__(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/output_devices.py", line 74, in __init__ super().__init__(pin, pin_factory=pin_factory) File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/mixins.py", line 75, in __init__ super().__init__(*args, **kwargs) File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/devices.py", line 540, in __init__ super().__init__(pin_factory=pin_factory) File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/devices.py", line 240, in __init__ Device.ensure_pin_factory() File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/devices.py", line 265, in ensure_pin_factory Device.pin_factory = Device._default_pin_factory() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/devices.py", line 297, in _default_pin_factory raise BadPinFactory('Unable to load any default pin factory!')gpiozero.exc.BadPinFactory: Unable to load any default pin factory!During handling of the above exception, another exception occurred:Traceback (most recent call last): File "/home/user/python/motor/motor-test-neu.py", line 16, in <module> Motor.Stop() ^^^^^NameError: name 'Motor' is not defined
Code:
pip install pigpiopip install rgpiopip3 install RPi.GPIO
RuntimeError: Cannot determine SOC peripheral base address
Full response:
Code:
(gunicorn) user@raspberrypi-assistent:~/python/motor $ python motor-test-neu.py from gpiozero import OutputDevice, DeviceDevice.pin_factory: NoneOutputDevice.pin_factory: None/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/devices.py:295: PinFactoryFallback: Falling back from lgpio: module 'lgpio' has no attribute 'SET_BIAS_DISABLE' warnings.warn(Motor stopTraceback (most recent call last): File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/pins/pi.py", line 408, in pin pin = self.pins[info] ~~~~~~~~~^^^^^^KeyError: PinInfo(number=18, name='GPIO24', names=frozenset({'24', 'WPI5', 'BCM24', 24, 'GPIO24', 'J8:18', 'BOARD18'}), pull='', row=9, col=2, interfaces=frozenset({'', 'dpi', 'jtag', 'gpio', 'sdio', 'spi'}))During handling of the above exception, another exception occurred:Traceback (most recent call last): File "/home/user/python/motor/motor-test-neu.py", line 10, in <module> Motor = DRV8825(dir_pin=24, step_pin=18, enable_pin=4, mode_pins=(21, 22, 27)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/python/motor/DRV8825.py", line 16, in __init__ self.dir_pin = OutputDevice(dir_pin) ^^^^^^^^^^^^^^^^^^^^^ File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/devices.py", line 103, in __call__ self = super().__call__(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/output_devices.py", line 74, in __init__ super().__init__(pin, pin_factory=pin_factory) File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/mixins.py", line 75, in __init__ super().__init__(*args, **kwargs) File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/devices.py", line 549, in __init__ pin = self.pin_factory.pin(pin) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/pins/pi.py", line 410, in pin pin = self.pin_class(self, info) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/python/gunicorn/lib/python3.11/site-packages/gpiozero/pins/rpigpio.py", line 101, in __init__ GPIO.setup(self._number, GPIO.IN, self.GPIO_PULL_UPS[self._pull])RuntimeError: Cannot determine SOC peripheral base addressDuring handling of the above exception, another exception occurred:Traceback (most recent call last): File "/home/user/python/motor/motor-test-neu.py", line 16, in <module> Motor.Stop() ^^^^^NameError: name 'Motor' is not defined
Code:
(gunicorn) user@raspberrypi-assistent:~/python/motor $ pip listPackage Version------------------ ----------blinker 1.7.0certifi 2023.11.17charset-normalizer 3.3.2click 8.1.7colorzero 2.0Flask 3.0.1gpiozero 2.0gunicorn 21.2.0idna 3.6itsdangerous 2.1.2Jinja2 3.1.3lgpio 0.0.0.2MarkupSafe 2.1.4packaging 23.2pigpio 1.78pip 23.0.1pygame 2.5.2requests 2.31.0rgpio 0.2.0.0RPi.GPIO 0.7.1setuptools 66.1.1urllib3 2.2.0Werkzeug 3.0.1
Clik here to view.

Clik here to view.

Clik here to view.

Thanks for any help!
Statistics: Posted by raspi_n00bie-lost — Wed Jan 31, 2024 4:26 pm