Libraries Installation for RPi

From Waveshare Wiki
Jump to: navigation, search

Libraries Installation for RPi

In order to use the API examples we provide, related libraries are required, which should be installed manually.

Install WiringPi Library

Click to download the wiringPi libraries, or you can also obtain the latest version from the WiringPi website:

https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/

Copy the installation package into your own system via a USB flash drive, enter the WiringPi folder, then do this to install:

chmod 777 build
./build

Run the following command to check the installation:

gpio –v

Install C Library bcm2835

Click to download the bcm2835-1.39 libraries or bcm2835-1.45 libraries. You can also obtain the latest version from the bcm2835 website: http://www.airspayce.com/mikem/bcm2835/

Copy the installation package into your own system, enter the bcm2835 libraries folder, then do this to install:

./configure
make
sudo make check
sudo make install

Install Python Library

Python Libraries for Raspbian (contain RPi.GPIO and spidev installation packages. See: https://pypi.python.org/pypi/RPi.GPIO https://pypi.python.org/pypi/spidev ) get it by apt-get commands.

Please take a note, your Raspberry Pi should be connected to the network when using the command apt-get to install the library. Before the installation, you can run the following command to update your software list.

sudo apt-get update
  1. Run the following command to install the package python-dev
    sudo apt-get install python-dev
  2. Installing the RPi.GPIO package (GPIO interface functions). Copy the installation package RPi.GPIO to your RPi board, and unzip it. Enter the unzipped file under the terminal, and run the following command to install the library:
    sudo python setup.py install
  3. Run the following command to install the library smbus (I2C interface functions)
    sudo apt-get install python-smbus
  4. Run the following command to install the library serial, which contains UART interface functions
    sudo apt-get install python-serial
  5. Installing the library spidev (SPI functions). Copy the installation package spidev to your RPi board, and unzip it. Enter the unzip file under the terminal, and run the following command to install the library:
    sudo python setup.py install
  6. Run the following command to install the Python imaging library
    sudo apt-get install python-imaging

Configuring the interfaces

(Before running the API codes we provided, you should start up the corresponding core drivers of the interfaces. In the ready-to-use system image file, both I2C and SPI are set to Enable by default, but the serial port is still in the terminal debugging function mode.)

  1. Enable the I2C function. Run the following command to configure your Raspberry Pi board:
    sudo raspi-config
    Select Advanced Options -> I2C -> yes, to start up the I2C core driver. Then you also need to modify the configuration file. Run the following command to open the configuration file:
    sudo nano /etc/modules
    Add the following two lines to the configuration file
    i2c-bcm2708
    i2c-dev
    Press the keys Ctrl+X to exit, and input Y to save the settings. Then, reboot the module to make the settings take effect.
  2. Enable the serial function. The serial port of RPi is set to serial terminal debugging function mode by default. If you want the serial port services as a common IO, you should modify the settings on the RPi. When the terminal debugging function is disabled, you cannot access RPi board via the serial port any more. If you want to control the RPi, you may need to enable the debugging function of the serial port again.
    sudo raspi-config
    Select Advanced Options -> Serial. Select the option no can disable the serial debugging function. And then, the serial port can be used for serial communication. And select the option yes can enable the serial debugging function. You should reboot the module to make the settings take effect.
Note: the serial port on Raspberry Pi 3 Model B is unusable, because Pin 14 and Pin 15 is connected to the on-board Bluetooth model.
  1. Start up the spi function, run the following command:
    sudo raspi-config
    Select Advanced Options -> I2C -> yes, to start up I2C core driver.