Original: http://www.cnblogs.com/hangxin1940/archive/2013/04/04/2999015.html
Previously described how to enable the I²c device http://www.cnblogs.com/hangxin1940/archive/2013/04/02/2997077.html and build a Python development environment HTTP// Www.cnblogs.com/hangxin1940/archive/2013/04/03/2997094.html
Quick2wire is a Python library for i²c communication on Raspberry Pi, which makes it easy to read and write Gpio pins with non-root users.
Why do you use it?
Some hardware devices for Linux, with high permissions, only root can operate, then in the development of these applications, to read and write some hardware devices, you have to have root identity, which brings the inconvenience, to know that the root user is the root of all evils , In case of Root, a inattention #:/ rm *
, it is really regret.
Preparatory work
sudo apt-get install gitsudo apt-get install python3sudo apt-get install python-pipsudo apt-get install python-virtualenv
Installing Quick2wire-gpio-admin
The Quick2wire-gpio-admin tool provides an easy way to enable/disable a GPIO pin, which does not require the current user to have root privileges.
Download the Uick2wire-gpio-admin source code in the appropriate location:
wget https://github.com/quick2wire/quick2wire-gpio-admin/archive/master.zip
Or
git clone https://github.com/quick2wire/quick2wire-gpio-admin.git
Unzip the downloaded zip file and go to the extracted directory
Compiling the installation
makesudo make install
At this point, it is installed, and it exists as a command in the system gpio-admin
.
Next, add the current PI user to the gpio
group
sudo adduser pi gpio
Exit and log in again to make sure that changes to the user group take effect immediately. For more information on this command, please visit https://github.com/quick2wire/quick2wire-gpio-admin
Installing QUICK2WIRE-PYTHON-API
QUICK2WIRE-PYTHON-API relies on quick2wire-gpio-admin, and we've done that in the last step.
This library makes it easy for developers to quickly connect to the Raspberry Pi pin using python
Download the QUICK2WIRE-PYTHON-API source code in the appropriate location:
wget https://github.com/quick2wire/quick2wire-python-api/archive/master.zip
Or
git clone https://github.com/quick2wire/quick2wire-python-api.git
Unzip the downloaded zip file and go to the extracted directory
Install this Python library
python3 setup.py install
At this point, the installation is complete.
For a more detailed example, check out the Https://bitbucket.org/thinkbowl/i2clibraries
For more information, please refer to:
Use Quick2wire to access the GPIO pin http://github.com/quick2wire/quick2wire-python-api/blob/master/doc/getting-started-with-gpio.md
Using Quick2wire to access the i²c pin http://github.com/quick2wire/quick2wire-python-api/blob/master/doc/getting-started-with-i2c.md
Using Raspi for I²c and ks103 communication via Quick2wire