Earthquake Detector

Uses

accelerometer, LED display, speaker, radio

Description

In this project, we will use the accelerometer to detect earthquake, and will buzz off sound if the intensity is high.

../../_images/earthquake-detector.jpg

An earthquake detector is technically called a seismograph, and it is able to detect subtle movements on the ground. The movement is usually recorded via a needle that will print a graph on a rotating paper. To simulate the needle and the paper, we will use the plotter function of the mu editor. It will plot any tuple values using the print() command. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.:

# a list
list1 = ['cats','dogs','zebras',1]

# a tuple
tuple1 = ('cats','dogs','zebras',1)

We will be using also the accelerometer to detect the movement. In this case, we will only use the x and y axis. We will be adding both x and y values to create a single value to plot. We will also subtract 1024 from the value since the most likely position of the microbit is upright and would be attached to a solid structure near the ground to detect subtle movements.

Basic Task

  1. Record the accelerometer values of x and y. If the micro:bit is upright, subtract 1024, if face-up, no need to subtract anything.
  2. Convert the resulting value to tuple(tuple(variable)) print it to REPL and plotter.
  3. If it detects a movement large enough, send a high signal to pin0 to sound off the buzzer (for micro:bit V1) or make a sound using audio.play().
  4. After flashing the microbit, continue to connect the microbit to usb and use the plotter function to monitor the seismic readings.
  5. You can upgrade this by using 2 microbit, where one microbit is placed on the field to detect movement, and the other is connected to the PC and monitor the reading. You will be using the radio function for this.
  6. Even better, you can create a weather monitoring station with 4 microbits, one for earthquake monitor, one for temperature measurement, one for wind monitoring (by dangling the microbit on a string and measure acceleration) and one for getting all the readings via radio and plotting all of it to a screen.