O'Reilly logo

Raspberry Pi Robotics Essentials by Richard Grimmett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

    Then select yes, as shown in the following screenshot:

    You'll also want to edit the file /etc/modules ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required