Raspberry Pi New User Cannot Access GPIO


Headnotes

Many equations and formulas look intimidating. However, when you hunt them down, they are definitely not! Just papertigers!

Now let's hunt the papertiger.

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

If the problem is still unsolved, try to deactivate your virtual enviroment if used. Otherwise, try to use

sudo chown root.gpio /dev/mem && sudo chmod g+rw /dev/mem

This both two commands have the same to do with each other.

sudo usermod -a -G target_group user_name
sudo adduser user_name target_group


Footnotes

There are many excellent tutorials out there. Some tutorials are too intuitive and it's helpful, but you cannot get it straight on the math details. Some focused on dymestifying math. Some focused on code. I found the best tutorials that give you the conceptual ideas and are possible for implementation without being blind to the math details. Drop a comment if I failed. It would be really appreciable.


If you want to cite this article, please cite this article as:

Lachlan Chen, "Raspberry Pi New User Cannot Access GPIO," in EarnFromScratch, 四月 24, 2019, https://www.earnfs.com/zh/html/1912.htm.

or

@misc{lachlanchen2020tutorial,
title=Raspberry Pi New User Cannot Access GPIO,
author={Chen, Lachlan},
year=四月 24, 2019
}


EarnFromScratch (九月 26, 2020) Raspberry Pi New User Cannot Access GPIO. Retrieved from https://www.earnfs.com/zh/html/1912.htm.
"Raspberry Pi New User Cannot Access GPIO." EarnFromScratch - 九月 26, 2020, https://www.earnfs.com/zh/html/1912.htm
EarnFromScratch 四月 24, 2019 Raspberry Pi New User Cannot Access GPIO., viewed 九月 26, 2020,<https://www.earnfs.com/zh/html/1912.htm>
EarnFromScratch - Raspberry Pi New User Cannot Access GPIO. [Internet]. [Accessed 九月 26, 2020]. Available from: https://www.earnfs.com/zh/html/1912.htm
"Raspberry Pi New User Cannot Access GPIO." EarnFromScratch - Accessed 九月 26, 2020. https://www.earnfs.com/zh/html/1912.htm
"Raspberry Pi New User Cannot Access GPIO." EarnFromScratch [Online]. Available: https://www.earnfs.com/zh/html/1912.htm. [Accessed: 九月 26, 2020]


发表评论