Other I2C sensors

There are many variations of magnetometers, accelerometers, gyroscopes, and so on. In some cases, the component has a single function, such as the module HMC5883L, which is just a magnetometer, or ADXL345 and MMA7660FC (part of contrib-drivers), which are accelerometers. In other cases, they are more complete, even proper 9 DoF (Degrees of Freedom) sensors like the ones on the phones, which are also known as IMUs (Inertial Measurement Unit).

Check whether a driver exists before deciding on a component, or be ready to write your own.

In most cases there are drivers already available, even if most of them are just ports from Arduino. The structure of the driver varies a bit but it is usually along the lines of what we saw in this chapter. In the case that there is no driver, you can always read the spec sheet of the component and write it yourself. It is not as complicated as it sounds, but nevertheless, it is a good idea to check for drivers before buying any component.

In general, I2C drivers provide easy-to-read variables and method names and simplify the commands you can send to the peripheral, providing an abstraction over the formatting of the communication protocol, but it is common that they just mirror whatever protocol the component has.

As a reference, we are going to look at the MPU6050 component, which is an accelerometer plus gyroscope (6 DoF).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.79.59