Reader small image

You're reading from  Raspberry Pi Robotic Projects - Third Edition

Product typeBook
Published inOct 2016
Reading LevelBeginner
Publisher
ISBN-139781786467966
Edition3rd Edition
Languages
Concepts
Right arrow
Authors (2):
Richard Grimmett
Richard Grimmett
author image
Richard Grimmett

Dr. Richard Grimmett has been fascinated by computers and electronics from his very first programming project, which used Fortran on punch cards. He has bachelor's and master's degrees in electrical engineering and a PhD in leadership studies. He also has 26 years of experience in the radar and telecommunications industries, and even has one of the original brick phones. He now teaches computer science and electrical engineering at Brigham Young University, Idaho, where his office is filled with his many robotics projects.
Read more about Richard Grimmett

Jon Witts
Jon Witts
author image
Jon Witts

Jon Witts has been working within the IT industry since 2002 and specifically within Educational IT since 2004. He was introduced to Linux back in 2001 through his collaboration with two German artists who were visiting the arts organisation he was then working with. Having studied Fine Arts and Educational Technology and sought to innovate with open and accessible digital technologies within his creative practice, Jon is happiest when deconstructing technology and finding its limits. Jon has embedded within his school the use of Raspberry Pi computers, as an integral part of the delivery of the school's Computer Science curriculum as well as to run various school clubs and projects. Jon is a Raspberry Pi Certified Educator and also helps to organise and run the Hull Raspberry Jam events. I would like to thank my wife, Sally and our three daughters for putting up with all the cables and compoents around the house, and not least for being so tolerant of the need to dodge the robots racing round the kitchen floor!
Read more about Jon Witts

View More author details
Right arrow

Accessing the compass programmatically


In order to access the compass capability you'll need to enable the I2C library on the Raspberry Pi. The first step to enable the IMU 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.

Enabling this bus is done by running sudo raspi-config, and selecting the Advanced Options, like this:

Once there, go to the I2C selection and enable the I2C, like this:

Say yes to all the selections to enable the I2C interface and load the library, then reboot the Raspberry Pi. Install the I2C tool kit by typing sudo apt-get install i2c-tools. You can see if the I2C is enabled by typing sudo i2cdetect -y 1, and you should see something like this:

You can see the device...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Raspberry Pi Robotic Projects - Third Edition
Published in: Oct 2016Publisher: ISBN-13: 9781786467966

Authors (2)

author image
Richard Grimmett

Dr. Richard Grimmett has been fascinated by computers and electronics from his very first programming project, which used Fortran on punch cards. He has bachelor's and master's degrees in electrical engineering and a PhD in leadership studies. He also has 26 years of experience in the radar and telecommunications industries, and even has one of the original brick phones. He now teaches computer science and electrical engineering at Brigham Young University, Idaho, where his office is filled with his many robotics projects.
Read more about Richard Grimmett

author image
Jon Witts

Jon Witts has been working within the IT industry since 2002 and specifically within Educational IT since 2004. He was introduced to Linux back in 2001 through his collaboration with two German artists who were visiting the arts organisation he was then working with. Having studied Fine Arts and Educational Technology and sought to innovate with open and accessible digital technologies within his creative practice, Jon is happiest when deconstructing technology and finding its limits. Jon has embedded within his school the use of Raspberry Pi computers, as an integral part of the delivery of the school's Computer Science curriculum as well as to run various school clubs and projects. Jon is a Raspberry Pi Certified Educator and also helps to organise and run the Hull Raspberry Jam events. I would like to thank my wife, Sally and our three daughters for putting up with all the cables and compoents around the house, and not least for being so tolerant of the need to dodge the robots racing round the kitchen floor!
Read more about Jon Witts