Accelerometer Tutorial#1: Working with an Accelerometer

Introduction: 3 Axis Accelerometer LIS2HH12 Module

Picture of 3 Axis Accelerometer LIS2HH12 Module

This tutorial is considered beginner level with some experience with arduino software and soldering.

There are at least two purposes of an accelerometer: To determine an angle in particular axes. (X,Y,or Z or all), or to determine acceleration change in an axes.

Accelerometers are used everywhere. They are used in:

Phones, Fitness bands, Drones, Robotics, Missiles, and Helicopters just to name a few. How you want to use an accelerometer is up to a person’s imagination.

Step 1: Materials

Picture of Materials

Materials you need are:

Arduino Nano or preferred arduino device

USB to Arduino Cable

LIS2HH12 Module,(Amazon link on the picture)

Wire Strippers and Wire, or Point to point Breadboard Jumpers

2x 10 Kohm resistors

Step 2: The Sesnor

Picture of The Sesnor
Picture of The Sesnor

LIS2HH12 module is based off the ST 3-Axis accerlerometer. The module is a tiny package and allows for 2 5-pin headers to be soldered to it. This mitigates vibration noise that is introduced to the accelerometer. from external sources of varying frequencies.

Main features for this chip are:
-Low-power mode 5uA draw
-16-bit resolution
-Performs +/-2 g,4 g,8 g
-0.2% noise
-I2C or SPI protocol
-Typical Voltage

Max Rating 4.8V (Do not go above 4.8 volts or you will break the Accelerometer chip)

Step 3: Project Platform

Picture of Project Platform

Project Platform for the accelerometer is Arduino.

The Development board I am using is a Arduino Nano.

Currently the Tinee9 LIS2HH12 accelerometer has only basic code for the Arduino but will be hopefully expanding the code for more technical projects and for Raspberry Pi or any platform that has enough fan base recommended by YOU. šŸ™‚

Step 4: Breadboard

Picture of Breadboard

If you have headers on both of your Arduino nano and LIS2HH12 Module you can put the Arduino Nano and accelerometer on the Breadboard like this, straddling the split line allowing access to the breakout pins.

Make sure the 3.3V pins on the Module is facing the Arduino.

If you do not have header on them get some and solder them to the boards.

Step 5: Placing Resistors on the Board

Picture of Placing Resistors on the Board

The I2C protocol that we will be using in this project needs 2 10 Kohm pull-up resistors to the supply rail on the chip (+3.3 Pins); one on the Clock line (CL) and one on the Data Line (DA)

Since the LIS2HH12 accelerometer max voltage is 4.8V and in this project we are using the 5V off of the Nano, I have placed a 100 ohm resistor from the 5V pin on the Nano to the red supply rail on the breadboard to bring down the supply rail a little.

Step 6: Connecting the Rest of the Board

Picture of Connecting the Rest of the Board

Now we are going to connect the rest of the module to the arduino.

The Gnd Pin on the module and arduino should have a jumper wires going from it to the Blue Rail on the Breadboard.

Connect the +3.3 Pin on the module to the red supply rail on the breadboard.

These last two step allowed us to power up the module when we power the arduino via battery or USB

Jumper Wire from the +3.3 Pin on the Module to the CS pin on the moduleĀ (This enables the I2C bus on the module)

Jumper wire from the Gnd Pin on the module to the A0 pin on the moduleĀ (This tells the accelerometer which address it will respond to when talking on the I2C Bus)

Jumper wire from A5 on the arduino to CL on the ModuleĀ (This allows the clock on the arduino to sync with the acceleromter.

Jumper wire from A4 on the arduino to DA on the moduleĀ (This allows the data to be transferred between the arduino and the module.)

Step 7: Download Files

Picture of Download Files

Go to Github addressĀĀ and download the files.

Go to this location on your computer

C:\Program Files (x86)\Arduino\libraries

Create a Folder Called Tiny9

Place the .h and .cpp Files in that Tiny9 Folder

Step 8: Open Up .ino

Picture of Open Up .ino

Open up the .ino file you downloaded in the Arduino IDE (Program/software)

Step 9: Upload Sketch

Picture of Upload Sketch

Once you have connected your arduino via USB cable to the computer, there should be a port number highlighted under tools tab in the arduino IDE.

My port happens to be COM 4 but yours might be 1 or 9 or something else.

If you have multiple COM options then choose the one that represents the Arduino that you are using. (How to determine which COM port for multiple choices can be on a different instructable if requested.)

Once you have the Arduino Port chosen, click the upload button.

Step 10: Enjoy

Picture of Enjoy

After it has finished Uploading you should be able to open the Serial Monitor in the Tool Tab and you should see something like this popping on your Monitor.

The Graph displays the x,y, and z axis in that order.

Z axis should say close to 1.0 +/- some counts because Z is pointing up.

Now you can rotate your breadboard and enjoy watching the numbers change showing you how the module’s axises are affected by gravity and acceleration.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s