Rpi4 GPIO?

I tried to run a python script and this is what I am getting...

$ python calib_fan.py
Traceback (most recent call last):
File "calib_fan.py", line 4, in <module>
import RPi.GPIO as GPIO
File "/usr/lib/python3.7/site-packages/RPi/GPIO/__init__.py", line 23, in <module> from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!

Am I missing something?
I am running Manjaro ARM with XFCE on RPi4

Where did you get the python script?
Does it support anything other than Raspbian?

This is where I got the script...

Did you install the RPi,GPIO python library in your environment?

Yes, I did. Version is 0.6.5-2

Okay. I don't know then. Maybe it checks for something only raspbian has.

I don't use GPIO's, so I don't know. :slight_smile:

Also, you sure it supports the Raspberry Pi 4?
According to this the error could be because the script detects a wrong chipset. The rpi4 uses a different chipset than the others.

Accorging to this

the latest version is 0.7.0..

but I am getting 0.6.5 as the latest version. Does anyone know why is that?

You uses pip install RPi.GPIO in your environment to get it?
I don't know much about how python modules work.

I installed the python-raspberry-gpio package. But now that I tried the pip install RPi.GPIO it also identifies the 0.6.5 as the latest version...

That's an AUR package and is defined as version 0.7.0 for me:

python-raspberry-gpio  0.7.0-1

Try rebuilding/reinstalling it.

Ok. I am running

sudo pacman -S python-raspberry-gpio

i get Old version 0.6.5-2
New version 0.6.5-2

Is there another command I should try?

Yeah. Pacman can't do AUR.

You should try with pamac instead:
pamac build python-raspberry-gpio

No. Same thing...

Warning: python-raspberry-gpio-0.6.5-2 is up to date -- reinstalling

Nevermind. I found the issue.
It's a package I put in the repo, totally forgot to update it. Give me a few minutes.

EDIT: Just updated the package in the repo. You should get it, next time your mirror syncs.

Ok! Thank you for your time! I'll check it, when it's available...

First post from a new user here.
I have also been recently playing around with PWM fan control on Raspi Pi 4.

Are you running your script with sudo? I found I got the same message if I ran my script as a user.
In the end I gave up using the GPIO Python module because it only does software PWM, and I found it would use 6% of a RaspiPi4 CPU just running the fan.

There is another library 'wiringpi' which will do hardware PWM, but that library does not currently work with Pi 4. (The author has updated it, but it is not available in Arch or Raspbian mirrors yet), and that library would not work with a Manjaro kernel because it checks for the Hardware and Revision lines in /proc/cpuinfo which are not present in Manjaro.

For an more elegant PWM solution there is a pwm dtoverlay available. Details are in the README in /boot/overlays and refer to this page Using-the-Raspberry-Pi-Hardware-PWM-timers

For my own solution I gave up on the idea of using PWM, because the fans were noisier with PWM than without, due to the windings buzzing at the PWM frequency. Instead I use two small 30mm fans set to turn on at different temperatures.

The git repo has not been updated in over a year....
And the main website says it's been depricated.

Forum kindly sponsored by Bytemark