O'Reilly logo

Internet of Things with Python by Gastón C. Hillar

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

Using the I2C bus to control a digital accelerometer with the mraa library

Sometimes, the features included in the upm library for a specific sensor do not include all of its possible usages and configurations. An example of this situation is the upmAdxl345.Adxl345 class that we used in our previous example. This class doesn't allow us to configure the desired scale for the accelerometer while the sensor supports the following four selectable measurement ranges: ±2g, ±4g, ±8g and ±16g. If we want to use specific features that aren't included in the upm module, we can use the appropriate mraa class to interact with the sensor, in this case, we can use mraa.I2c to control the digital accelerometer through the I2C bus.

We will use the C++ source code ...

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