Exploring Seismic Motions with an Arduino

In my Earthquakes and Society course I use an arduino and MEMs sensor to introduce students to seismograms and to help them develop an intuitive understanding of seismogram analysis. The idea is to have them build their own sensors and explore the motions they can produce with the simple system (while it is connected to the computer in the classroom). The picture is pretty much all the information they need to connect the hardware, but I provide a little background on a breadboard, etc. Within a few minutes, non-science students are quite comfortable with the system.

Arduino accelerometer system. The arduino is the larger board, the small breakout contains an accelerometer.

The arduino is an easy-to-use microprocessor that you program with a C++ code (the program or “sketch” as they are called, that we use in the classroom is listed below). They use the Arduino IDE to watch the numbers stream out of the arduino, and then use the “serial plotter” to see the accelerations much the way we look at seismograms. You can have them move the accelerometers in different directions and look at the signals, move the sensor quickly or slowly, or even in a circle. They see (and make) patterns similar to what we see on seismograms. This gives them an intuitive appreciation for the types of vibrations that we record on earthquake-monitoring systems.

Next I show students the three-component accelerations recorded on the floor of my car as I drove across town and I ask them to analyze the motions. They identify everything from stop signs, red lights, and pothole bumps, to left and right turns. They reconstruct what I was doing from the wiggly lines – just as seismologists do for earthquakes.

Sample output from the arduino seismometer plotted in the Arduino IDE using the Serial Plotter Tool. Red is vertical, orange is Y, and X is green.

The Arduino Code

I use an arduino Uno and a MM8451 breakout board from http://adafruit.com along with the libraries supplied at that site. The code is quite simple and is listed below.

Simple sketch to list elapsed time, gx,gy,gz to serial connection
// the accelerometer (a global variable)
Adafruit_MMA8451 mma = Adafruit_MMA8451();
void setup(void) {
// Open serial communications.
// Check for and setup up the accelerometer
if (! mma.begin()) {
Serial.println("Couldnt start");
while (1);
void loop() {
int i,navg = 40;
float gx,gy,gz;
sensors_event_t event;
// average navg values (box-car filter)
gx = 0.0;
gy = 0.0;
gz = 0.0;
gx += event.acceleration.x;
gy += event.acceleration.y;
gz += event.acceleration.z;
gx = gx / (float)navg;
gy = gy / (float)navg;
gz = gz / (float)navg;
// output
//Serial.print(0.001*millis(),5);Serial.print(" ");
Serial.print(gx,3);Serial.print(" ");
Serial.print(gy,3);Serial.print(" ");

Estimating Earth’s Mass

We also connect the four-wire accelerometer system to Mathematica, average 100 values of the vertical acceleration and use that with Newton’s Law of Gravitation to estimate the mass of Earth. The values are really close to the accepted value. This is likely a bit circular since I suspect, but don’t know, that the accelerometer is calibrated to produce the correct vertical acceleration.


Using arduino hardware in the classroom takes some time. I usually spend three class periods working with students to overcome problems with connections, software glitches, that arise. All of this is a good mini-lesson in what it is like to do science (at least observational seismology).