How To Make An Earthquake Detector with Raspberry Pi Pico?

Hi there. You know in Turkiye there have been huge earthquakes. As a result of the earthquakes that occurred in Turkiye on February 6, 2023, thousands of people lost their lives under the rubble, and millions of people had to live in tents. The fact that earthquakes occur during sleep hours increases the loss of life. In this project we will make an earthquake sensor using tilt sensor and Raspberry Pi Pico.

Earthquake Detector With Raspberry Pi Pico

First we need components for this project as list below:

1x Tilt sensor

1x 5v Buzzer

1x Raspberry Pi Pico

First, you will need to connect the tilt sensor to the Raspberry Pi Pico. The tilt sensor usually has two pins that need to be connected to two GPIO pins on the Raspberry Pi Pico. One pin is connected to GND, and the other pin is connected to a GPIO pin, such as GPIO 2. And also we connect buzzer to GPIO 28 pin. You can see connection at the diagram as below.

Raspberry Pi Pico Earthquake Detector Connection Diagram

Here is the Python code for the tilt sensor:

import machine
import utime

# Set up the GPIO pin as 2 for the tilt sensor
tilt_sensor_pin = machine.Pin(2, machine.Pin.IN)

# Set up the buzzer on the board to indicate an earthquake
buzzer = machine.Pin(28, machine.Pin.OUT)

while True:
    # Read the tilt sensor value
    tilt_sensor_value = tilt_sensor_pin.value()

    # Check if the tilt sensor is tilted
    if tilt_sensor_value == 1:
        # If the tilt sensor is tilted, turn on the Buzzer
        buzzer.value(1)

        # Wait for 1 second
        utime.sleep(1)

        # Turn off the Buzzer
        buzzer.value(0)

    # Wait for a short time to avoid unnecessary processing
    utime.sleep(0.1)

This code reads the value of the tilt sensor every 100 milliseconds. If the tilt sensor is tilted, it turns on buzzer on the board for one second, indicating an earthquake. The program then turns off the buzzer and waits for a short time to avoid unnecessary processing.

Note that this program is just a simple example to show you how to use a tilt sensor with Raspberry Pi Pico. A more sophisticated earthquake detector would require additional sensors and signal processing algorithms to accurately detect and measure the intensity of an earthquake. But you can use this for experimental purposes.

Leave a Reply

Your email address will not be published. Required fields are marked *