Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi Robotics Essentials

You're reading from   Raspberry Pi Robotics Essentials Harness the power of Raspberry Pi with Six Degrees of Freedom (6DoF) to create an amazing walking robot

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781785284847
Length 158 pages
Edition 1st Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Richard Grimmett Richard Grimmett
Author Profile Icon Richard Grimmett
Richard Grimmett
Arrow right icon
View More author details
Toc

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:
    Accessing the compass programmatically

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

    Accessing the compass programmatically

    Then select yes, as shown in the following screenshot:

    Accessing the compass programmatically

    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:

    Accessing the compass programmatically

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

    Accessing the compass programmatically

    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:
    Accessing the compass programmatically

    You can see...

lock icon The rest of the chapter is locked
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 $19.99/month. Cancel anytime
Banner background image