Raspberry Pi New User Cannot Access GPIO

wiringPiSetup: Unable to open /dev/mem or /dev/gpiomem: Permission denied.
Aborting your program because if it can not access the GPIO
hardware then it most certianly won’t work
Try running with sudo?

sudo usermod -a -G gpio user_name % change the owner and group respectively sudo chown root.gpio /dev/gpiomem sudo chmod g+rw /dev/gpiomem [Read More]

Raspberry Pi, GPIO, Python, C/C++ Extension and wiringPi Connected

I used gpiozero and RPi.GPIO to control my 3D printer. However, the speed is quite slow. After some nervewracking thinking, I found it the python that cause the slow motion of those motors. Even I delete the time.sleep() line, it still run slowly. This give me no choice that I have to rewrite my control module into c code. After the rewriting, the problem finally solved.

In the c code, I choose wiringPi library to control the GPIO.

The numbering system of the gpiozero and RPi.GPIO with wiringPi is quite different. You should use

gpio readall

to get the number map of your Pi.

Next you should wrap your c code in python.

Create a file test.c

and a file setup.py

Once the coding is finished, you should build and install you code. I suggest you install this in a virtual environment.

sudo apt install python-virtualenv python setup.py build python setup.py install [Read More]