I cannot access the GPIO pins without running as root, i get the following error from python:
RuntimeError: Cannot determine SOC peripheral base address.
the same code runs without issue on a pi500
I cannot access the GPIO pins without running as root, i get the following error from python:
RuntimeError: Cannot determine SOC peripheral base address.
the same code runs without issue on a pi500
Nothing to do with the platform, you need to make sure you add the gpio group to your account:
Using the following:
sudo usermod -aG gpio <yourAccountHere>
gpio is needed, however you may want to add i2c and spi as well. Note you will need to log out and log back in to enable the group(s) addition
Thanks, I already tried that but still get:
RuntimeError: Cnnot determine soc base address
when I run my code
Not knowing that you are trying to do makes this a little more difficult, however:
You may need rpi-lgpio instead, or use gpiozero.
I am pretty certain the code was running with sudo & as per my original post was working fine on a Pi500, I will create a minimum code example & post later if it still fails.
Copy the following and run it… using python3
import RPi.GPIO as GPIO
import time
WAIT_TIME = 1
class GetCaseFanSpeed:
TACH = 18
PULSE = 2
def __init__( self, tachPin = TACH):
self._tachPin = tachPin
self._rpm = 0
self._t = time.time()
self.GPIO = GPIO
self.GPIO.setmode( self.GPIO.BCM )
self.GPIO.setwarnings( False )
self.GPIO.setup( self._tachPin, self.GPIO.IN, pull_up_down=self.GPIO.PUD_UP )
self.GPIO.add_event_detect( self._tachPin, self.GPIO.FALLING, self._calcRPM )
def __del__( self ):
self.GPIO.cleanup()
def _calcRPM( self, n ):
dt = time.time() - self._t
if dt < 0.005: return # Reject spuriously short pulses
freq = 1 / dt
self._rpm = (freq / GetCaseFanSpeed.PULSE) * 60
self._t = time.time()
@property
def RPM( self ):
return self._rpm
if __name__ == "__main__":
fanSpeed = GetCaseFanSpeed()
try:
for i in range( 10 ):
print( f"{fanSpeed.RPM:.0f} RPM" )
time.sleep( 2 )
except KeyboardInterrupt:
GPIO.cleanup()
i am still getting the same error,
very confusing as this is a stock install
Its gotta be incorrect libraries…
I think you are correct
sudo apt reinstall python3-rpi-lgpio
did the trick for your code, now to start debugging mine again ![]()
one last question How do I get it includes in a python venv
python -m venv (venvname) does not seem to include it
You need to make sure that the libraries are installed in the python venv.
Thanks, I sorted that & then found then installing the Pimoroni Blinkt library over wrote it, restoring the correct version solved the initial error & revealed som incompatabilities in the pimoroni libruary that I am working through.
many thanks for the pointers