Click here to read Part 2 of this article >
We covered the basics of accelerometer previously in Using Arduino with Parts and Sensors – Accelerometer Part 1 and Using Arduino with Parts and Sensors – Accelerometer Part 2. Today we’ll be testing KX022-1020 accelerometer using TFT liquid crystal panel. We’ll discuss how to control the TFT LCD in more detail in the next article. In addition, we’ll further explore Arduino Create. For more information about Arduino Create, please refer back to this article.
Estimated time to complete: 90 minutes
Parts needed:
※ Rohm sensor evaluation kit can be purchased from the following site!
Let’s briefly review what accelerometer is. An accelerometer is a sensor that can detect the state of motion, such as “tilt,” “shock,” “vibration” and so forth. Accelerometers are classified into one axis, two axes, and three axes. For example, one axis detects one direction (vertical only); two axes detects two directions (vertical and horizontal); and three axes three directions (vertical, horizontal and height).
Since the accelerometer integrated in the Sensor Evaluation Kit has three axes, it’s able to detect XYZ coordinates.
Figure 1. Accelerometer (KX022-1020)
KX022-1020 is a 3-axis accelerometer. There is a display of XYZ on the sensor like the geomagnetic sensor.
Now, let’s test the accelerometer. Download the library from the “Software” section at the bottom of the accelerometer page from the Rohm Sensor Evaluation Kit website.
Figure 2. Accelerometer page
We’ll continue using Arduino Create Web Editor as we did in our last tutorial. To add the library, you can upload the zip file by selecting it from “Libraries” on the left menu and clicking on “ADD ZIP LIBRARY.”
Figure 3. Arduino Create Web Editor – Adding Library
After adding the library, attach the accelerometer to the Sensor Shield (I2C I/F) and try running the sample program. The accelerometer should be set to 1.8V or 3.0V.
Figure 4. Attaching the accelerometer to the Sensor Shield
To open the sample program, click on “Libraries” and then “KX022” under “CUSTOM”.
Figure 5. Arduino Create Web Editor – Opening sample program
After compiling and uploading it to Arduino, you’ll able to see values displayed on the serial monitor.
Figure 6. Values shown on Arduino Create serial monitor
Now the sample program is working fine, let’s try to display the values on a 1.8 inch TFT LCD monitor. Although this TFT liquid crystal monitor has a resolution slightly smaller than 126 x 160 px, it’ll be quite useful when displaying numbers or letters with Arduino etc.
In the past, we used 7-segment LED to display numerical values only. But this time, I tried to display the graph along with the values obtained from the accelerometer.
Figure 7. 1.8 inch TFT liquid crystal monitor
Figure 8. SD card slot on the back of the TFT LCD monitor
Figure 9. Connecting TFT monitor to Sensor Evaluation Kit
When using the TFT monitor, the connection method and the library used in the program may be different depending on the specification of each TFT monitor. The TFT monitor used in this tutorial is a monitor SainSmart ST7735R. In addition to Arduino, the monitor is also compatible with Raspberry.
In order to use the monitor to run the program in Arduino, we’ll have to modify the downloaded library a little bit. We’ll go over how to control the TFT LCD in more detail in the next article. Once everything is set, you will be able to output numerical values in the monitor as shown in the video below:
In the next part, we’ll create a simple device using the same accelerometer and TFT monitor. We’ll show how to create graphs and display the values obtained from the accelerometer on the TFT monitor.