Using an Arduino to Read an Accelerometer

1. Introduction

In this lecture, we used an Arduino Uno R3 to read the values from an MPU6050 via the I2C protocol. These values were then displayed on seperate plots.  

2. The Code and the Results

In Figure 1 we can see the wiring to the Arduino used for both tasks.

  

Figure 1. The Arduino wiring used for both tasks

In Figure 2 we see the code from Task 1 with the filled in missing portions from the example code.

Figure 2. The code used to generate plots for Task 2

In Figure 3 we see the acceleration plots generated from Task 1.

Figure 3. Acceleration in the X-axis, Acceleration in the Y-axis, Acceleration in the Z-axis, from top to bottom.

In Figure 4 we see the code from Task 2 with the filled in missing portions from the example code.

Figure 4. The code used to generate plots for Task 1

In Figure 5 we see the plots generated from Task 2.

Figure 5. Angle in the X-axis, Angle in the Y-axis, Angle in the Z-axis, from top to bottom.

2. Discussion

This lab was a great look into using a basic sensor via the I2C protocol. Being able to access multiple devices along the same pins is very useful in a situation where very few pins are available. The MPU6050 is also a standard device which was good to get familair with.