Getting ready

To use the I2C bus using Python 3, we will use Gordon Henderson's WiringPi2 (see http://wiringpi.com/ for more details).

The easiest way to install wiringpi2 is by using pip for Python 3. TheĀ pip is a package manager for Python that works in a similar way to apt-get. Any packages you wish to install will be automatically downloaded and installed from an online repository.

To install pip, use the following command:

sudo apt-get install python3-dev python3-pip  

Then, install wiringpi2 with the following command:

sudo pip-3.2 install wiringpi2

Once the installation has completed, you should see the following, indicating success:

Successfully installed WiringPi2

You will need the PCF8591 module wired as it was previously used in the I2C connections of the Raspberry Pi:

The PCF8591 module and pin connections to the Raspberry Pi GPIO connector