So you are trying to program the Raspberry expansion PINS in Python, for example for this 3D LED Christmas Tree, and you’re getting the error:
GPIO.setup(self.number, GPIO.IN, self.GPIO_PULL_UPS[self._pull])
RuntimeError: Not running on a RPi!
I’m running this on Ubuntu 20.04LTS with a Raspberry 4.
The first thing:
Make sure you have an official Raspberry Pi charger.
Or at least, make sure your USB charger provides enough intensity to power the Raspberry and the LEDs.
The LED power comes from the motherboard and if Raspberry Pi has not enough energy this is not going to work.
My colleague Michela had her tree not working because of the charger was not able to provide enough energy. When she ordered a new charger, it worked like a charm.
Install the base Software
In order to communicate with General Purpose Input Output ports (GPIO) you need to install this Software:
sudo apt install python3-pip python3-gpiozero sudo pip3 install giozero
In order to run the 3D LED Christmas Tree code samples
sudo pip3 install colorzero sudo pip3 install rpi.gpio --upgrade
It may be not required in some cases.
Download the Source code
Run the samples as root
I saw many people stuck, in the forums, because of that.
To work with the LEDs you need to run the samples as root.
Where I used it?
I used it in my Open Source monitor Software CTOP.py in order to show the plugins/extensions capability of it. :)