Raspberry Pi uses the python quick2wire library to develop I2C applications

Source: Internet
Author: User
How to enable I2C device http://www.cnblogs.com/hangxin1940/archive/2013/04/02/2997077.html and build a python I2C Development Environment http://www.cnblogs.com/hangxin1940/archive/2013/04/03/2997094.html

Quick2wire is a python library used for I2C communication on Raspberry Pi. It allows non-root users to read and write gpio pins conveniently.

Why use it?

Some hardware devices have high permissions for Linux and can only be operated by the root user. Therefore, when developing these applications, you must have the root identity to read and write some hardware devices, this brings inconvenience. You Need To Know That * the root user is the root of all sins *. In case of root identity, leave the root user alone '#:/RM *', that's a pity.

# Preparations

Sudo apt-Get install git
Sudo apt-Get install python3
Sudo apt-Get install Python-pip
Sudo apt-Get install Python-virtualenv

# Install 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 source code of the uick2wire-gpio-admin in a proper location:

Wget https://github.com/quick2wire/quick2wire-gpio-admin/archive/master.zip

Or

Git clone https://github.com/quick2wire/quick2wire-gpio-admin.git

Decompress the downloaded ZIP file and enter the decompressed directory.

Compile and install

Make
Sudo make install

In this case, the installation is completed. It exists with the 'gpio-admin' command in the system.

Next, add the current PI user to the 'gpio' group.

Sudo adduser PI gpio

Log out and log on to the system to make sure that changes to the user group take effect immediately. For details about this command, go to the https://github.com/quick2wire/quick2wire-gpio-admin

# Install quick2wire-python-api
The quick2wire-python-api depends on the quick2wire-gpio-admin, and we have done it in the previous step.

This library allows developers to quickly connect to Raspberry Pi pins using python.

Download the source code of the quick2wire-python-api in a proper location:

Wget https://github.com/quick2wire/quick2wire-python-api/archive/master.zip

Or

Git clone https://github.com/quick2wire/quick2wire-python-api.git

Decompress the downloaded ZIP file and enter the decompressed directory.

Install this python Library

Python3 setup. py install

Now, all installation is complete.

For more detailed examples, check out the https://bitbucket.org/thinkbowl/i2clibraries

For more information, see:

Access gpio pin http://github.com/quick2wire/quick2wire-python-api/blob/master/doc/getting-started-with-gpio.md with quick2wire

Access I2C pin http://github.com/quick2wire/quick2wire-python-api/blob/master/doc/getting-started-with-i2c.md with quick2wire

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.