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 ...

Get Internet of Things with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.