As previously noted, we’ve had a few earthquakes. A feature of the period after a large quake is that there are many aftershocks. The name aftershock gives the wrong idea. Aftershock means earthquake and we have had over 7000, up to magnitude 6.3, close to our city.

The frequent occurrence of  nearby aftershocks was an opportunity to get some measurements of our own and learn more about seismology and what was happening under our city.

Here’s a magnitude 5.4 quake that we captured in the evening of 21 June. The quake was centred about 12km away.

The three graphs show the ground acceleration in all three dimensions. The Y-axis is north-south and the Z-axis is vertical acceleration. The units of acceleration are expressed as a percentage of Earth’s gravity. The peak acceleration we experienced in this quake was about 9%g, about 880mm/s2.

Looking at the Z-axis graph, you can clearly see the higher frequency P-wave, arrive just over a second before the lower frequency S-wave. The difference in propagation speed between the P and S waves is about 8km/s.

I used a Fourier transform to extract the constituent frequencies of the shaking, from the accelerometer data. The top graph shows strong peaks in the three to five Hertz range for the S-wave. The P-wave around 20Hz is clear in the Z-axis plot.

Fourier transform - x-axis

Fourier transform - z-axis

You can see the accelerations at other points in the city on the shaking map on the GeoNet website. First zoom in the central Christchurch, then select PGA from the Add Instrument Shaking drop-down menu. Put your mouse over the square icons to see the ground acceleration. Close to the quake, the accelerations reached 60%g, strong enough to cause damage.

How was it done

There are many designs for amateur seismographs. The best known are from Scientific American articles, Lehman seismograph from 1979 and the Shackleford-Gundersen design from 1975. Both these instruments involve a fair amount of mechanical fabrication and electronics.

So to get something working quickly we used a Bosch micro-machined accelerometer chip, which which can record nearby quakes with strong ground acceleration, i.e. like those we have been experiencing. This type of instrument is classed as a strong motion accelerograph.

The instrument is built around an Arduino Mega2560, using microSD storage. A ChronoDot provides timekeeping. An LCD display and a couple of LED’s provide status information.


The Bosch BMA180 has the best performance of all the devices I tried. It is a digital sensor with a high sample rate, SPI and I2C interfaces and built-in low-pass filters. The seventy page datasheet is a little intimidating.

I also tried a Freescale MMA7260Q and Analog Devices ADXL345 accelerometers. Both devices had lower sample rates and higher noise floors than the Bosch device. The ADXL345 would be adequate for this application. These sensors are all MEMS technology.

The BMA180 is powered from the Arduino 3.3V pin and connected directly to the I2C pins (pins 20 and 21).

The program uses a timer to trigger an interrupt to read the accelerometer at regular intervals. A sample rate of 200Hz is more than adequate for seismic signals, which are below 20-30Hz.

The main limitation of MEMS accelerometers is the noise level. A magnitude 3.7 quake within about 15km is the lower limit for getting a good signal.

Data capture

 The original plan was to transmit the data direct to a PC, via ethernet. However, given that mains power failures often accompany stronger quakes, this perhaps wasn’t the best possible solution.

The Arduino Ethernet shield also has built-in microSD card slot. This can easily write the accelerometer data to the microSD card faster than it is captured.

When an event is detected the data in the ring buffer is written to the microSD card and the program keeps writing for several seconds after the end of the event.

A ring buffer is a common pattern for capturing data. Readings are added to the end of the buffer until it is full. At that point the oldest reading is overwritten. In this program, the accelerometer is read continuously and data is stored in a ring buffer 399 points long. When an event is triggered the main program loop writes data from the buffer to the microSD card, as long as the recording continues. A standard Arduino doesn’t have enough RAM for this size ring buffer, hence the Mega2560.

Using a ring buffer with a timer ensures that the samples are read at even intervals regardless of the timing of writing data to the microSD card. Since there are already 399 samples in the buffer at the start of the event, the recording includes data for two seconds before the event was detected.

A series of consecutive readings above the noise threshold triggers recording and it continues for several seconds after the signal drops below the threshold. Once the event is complete, the file is closed and another one opened.


When there is a powerful earthquake the electrical power distribution system shuts down to protect itself. Battery backup ensures continuous recording even if mains power fails.

The Sparkfun combination LiPoly charger and boost converter makes this easy. The board supplies power to the instrument and charges the LiPoly battery. If the power fails, the boost converter on the board supplies regulated 5V to the Arduino board. Power is wired directly to the 5V pin on the Arduino.

The 1200 mAh battery can run the unit for 5-6 hours. More if the LCD backlight is disconnected.

Data Processing

I used Microsoft Excel to process the comma-delimited text files from the microSD cards and make the graphs. The Excel Analysis Toolpack includes a Fast Fourier Transform function.

More things to try

  • look for ways of reducing accelerometer noise
  • add web server to the instrument to remotely read status and download data
  • automated processing
  • alternate sensors, e.g a geophone or one of the designs from Scientific American


The Arduino sketch can be downloaded, or cloned from the bitbucket repository

About these ads