Head office, Rana Pratap Bagh, Delhi011 2721 1512+91 97116 99511

Science project idea

Earthquake alarm with an MPU6050 that cuts a 12 V supply through a relay

An MPU6050 accelerometer measures shaking on three axes. When the vibration stays above a level for a short time, the Arduino sounds a siren, flashes a light and opens a relay that cuts a 12 V model lighting circuit, as a real system might cut gas or power during a quake.

What it shows

An MPU6050 accelerometer measures shaking on three axes. When the vibration stays above a level for a short time, the Arduino sounds a siren, flashes a light and opens a relay that cuts a 12 V model lighting circuit, as a real system might cut gas or power during a quake.

The science

The accelerometer gives acceleration on x, y and z axes over I2C, with gravity showing as about 1 g on the vertical axis at rest. The sketch computes the vector magnitude and subtracts 1 g; the remainder is vibration. A quake is a sustained shake, so the code requires the vibration to exceed a threshold for at least half a second, which filters out a bump on the table. The relay is wired through its normally closed contact so the strip is lit in normal operation and cut when the coil is energised.

Materials

Cost: under Rs 1,500. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.

  • An Arduino Uno clone and USB cable
  • An MPU6050 accelerometer and gyro module
  • A 5 V relay module
  • A 12 V LED strip with its adapter
  • A buzzer and a red LED with a 220 Ω resistor
  • A 16x2 I2C LCD
  • A wooden base and jumper wires

Safety

For this project: The relay interrupts only the 12 V strip; this is not a replacement for any real safety cut-off. An adult must check the adapter wiring.

Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.

All the safety rules

Step by step

9 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.

  1. Wire the MPU6050: VCC to 5 V (the module has a regulator), GND to GND, SDA to A4, SCL to A5.

  2. Install an MPU6050 library and run its raw data example; confirm the z axis reads about 16384 (1 g) at rest.

  3. Convert the three axes to g, compute the magnitude with sqrt, and print the difference from 1 g.

  4. Wire the buzzer to pin 6, the LED to pin 7 through its resistor, the relay IN to pin 8 and the LCD to A4 and A5.

  5. Connect the strip through the relay COM and NC terminals to the 12 V adapter so it is lit when the relay is off.

  6. Set a threshold around 0.3 g and require it for 500 ms before declaring a quake.

  7. On a quake, energise the relay (strip goes dark), sound the buzzer in a rising pattern and show EARTHQUAKE on the LCD.

  8. Keep the alarm latched until a button on pin 2 is pressed, then restore the strip.

  9. Mount the module firmly on the base and test by shaking the table steadily versus a single tap.

What you should see

Steady shaking for half a second triggers the alarm and cuts the strip; a single knock does not. The LCD shows live vibration in g.

Viva questions

A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.

1Why subtract 1 g?

Gravity always acts on the sensor; removing it leaves only the shaking acceleration.

2Why use the normally closed contact?

So the strip is normally lit and the relay only needs power during the cut-off, like a real safety cut.

3What is the difference between an accelerometer and a gyroscope?

The accelerometer measures linear acceleration; the gyroscope measures rate of rotation.

4How would a real system avoid false alarms from trucks?

By comparing several sensors in different places and using frequency analysis of the shaking.

Free ebook: Viva Questions for Science Projects

Take it further

Record the peak g of each event to EEPROM and display the last five events.

Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.

Free ebooks for this project

WhatsApp us