Book Image

Raspberry Pi Robotics Essentials

By : Richard Grimmett
Book Image

Raspberry Pi Robotics Essentials

By: Richard Grimmett

Overview of this book

Table of Contents (14 chapters)
Raspberry Pi Robotics Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Accessing the compass programmatically


In order to access the compass capability, you'll need to enable the I2C library on Raspberry. If you used the IR sensor and ADC additional hardware in Chapter 4, Avoiding Obstacles Using Sensors, you will have already done this. If not, follow these instructions to enable the I2C interface:

  1. Run raspi-config. Select the Configure advanced settings, as shown in the following screenshot:

    From the next selection page, select the Enable/disable automatic loading of the I2C interface, as shown in the following screenshot:

    Then select yes, as shown in the following screenshot:

    You'll also want to edit the file /etc/modules and add the lines i2c-bcm2708 and i2c-dev, as shown in the following screenshot:

    And one final edit, change the last line in /boot/config.txt, as shown in the following screenshot:

    Now, reboot Raspberry Pi.

  2. With the device connected, you can see if the system knows about your device. To do this, type the following command:

    You can see the device...