Book Image

Raspberry Pi Sensors

By : Rushi Gajjar
Book Image

Raspberry Pi Sensors

By: Rushi Gajjar

Overview of this book

Table of Contents (16 chapters)
Raspberry Pi Sensors
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Preface
Index

Installing useful libraries


I compare this section to an ice cream with chocolate sauce (yummy! ssrupp!). If you have a vanilla ice cream in your hand, you can enjoy the ice cream, but once you pour chocolate sauce on that, it becomes more delicious, doesn't it? Adding and installing libraries in the RasPi is the same scenario. The RasPi is amazing with the added libraries, which can give you the functionalities you want, whether it is on the GPIO or on the camera port. A library is a particular set of functions that gives you easiness while writing the programs.

Step by step, we will install the useful libraries. To install the libraries, all you need is an Internet connection on the RasPi via PuTTY, as explained in previous sections.

Tip

Before installing any libraries, verify that your operating system has the latest update. Always check for upgrades and updates by entering these commands:

sudo apt-get update
sudo apt-get upgrade

Here, we update the RasPi to provide information on the latest package versions and dependencies. All the repositories will get information about their latest packages and to resynchronize. In the next step, upgrade will fetch new versions of packages according to the list provided in the update list. This process will take time, depending on the size of the update and the quality of the Internet connection.

git-core

git is a code management system used for collaborative work among programmers across the world, and it makes tracing change in the code easy. You will find many libraries and projects on git. If you know the source repository, you can directly get the library using git-core. Install git-core using this command:

sudo apt-get install git-core

wiringPi

The wiringPi library is created by Gordon, written in C, and provides you with support to extend your C programs to control the GPIOs. You can easily download (which will need the Internet connection shared on the RasPi) this library from Gordon's git core profile by typing the following command:

git clone git://git.drogon.net/wiringPi

The RasPi then downloads the library and creates a folder in the root directory. Use the cd wiringPi command to change the directory and go to the wiringPi directory. The next command to be entered is git pull origin, which fetches the latest version, and then we are ready to build the script using the ./build command.

Now, once the build process is done, we are ready to use the wiringPi library in any C program we write in the future. To check whether this particular library is working perfectly, enter these commands: gpio -v and gpio readall. This will convince you that you have installed it correctly. In Chapter 2, Meeting the World of Electronics, you will learn how to use wiringPi in shell script and the C language.