Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi Sensors

You're reading from   Raspberry Pi Sensors Integrate sensors into your Raspberry Pi projects and let your powerful microcomputer interact with the physical world

Arrow left icon
Product type Paperback
Published in Apr 2015
Publisher
ISBN-13 9781784393618
Length 192 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Rushi Gajjar Rushi Gajjar
Author Profile Icon Rushi Gajjar
Rushi Gajjar
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Meeting Your Buddy – the Raspberry Pi FREE CHAPTER 2. Meeting the World of Electronics 3. Measuring Distance Using Ultrasonic Sensors 4. Monitoring the Atmosphere Using Sensors 5. Using an ADC to Interface any Analog Sensor with the Raspberry Pi 6. Uploading Data Online – Spreadsheets, Mobile, and E-mails 7. Creating an Image Sensor Using a Camera and OpenCV A. Shopping List 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.

You have been reading a chapter from
Raspberry Pi Sensors
Published in: Apr 2015
Publisher:
ISBN-13: 9781784393618
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime