O'Reilly logo

Raspberry Pi Robotic Blueprints 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

Now that the device is connected, you'll need to configure access via the software. Following are the steps:

  1. In order to access the compass capability, you'll need to enable the I2C library on Raspberry. The first step in enabling the analog-to-digital converter (ADC) is to enable the I2C interface. The I2C interface is a synchronous serial interface and provides more performance than an asynchronous Rx/Tx serial interface. The SCL data line provides a clock while the data flows on the SDA line. The bus also provides addressing so that more than one device can be connected to the master device at the same time. To enable this bus, run sudo raspi-config and select the 8 Advanced Options, as follows:

  2. Then ...

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