How to Build an Earthquake Sensor With Arduino

by aaron smith in Circuits > Arduino

1012 Views, 3 Favorites, 0 Comments

How to Build an Earthquake Sensor With Arduino

arduino uno.png
circuit diagram.png

Look no further if you’re looking for a practical project to make using the excellent Arduino platform. Today we’re going to make an earthquake sensor with just a few parts and the Arduino Uno. For those who don’t know, Arduino is an open-source electronic computer learning platform that allows for quick prototyping and developing hobby, scientific, and educational projects. This is one such project!

Supplies

microcontroller.png
supplies.jpg
jumper wires.png
buzzer.png
laptop and usb.jpg

Materials we’ll need:

  1. Arduino Uno 
  2. Buzzer
  3. Jumper wires
  4. Vibration Sensor
  5. Laptop with IDE installed
  6. USB cable

Prep Your Arduino

arduino uno.png

Once you have all the parts, we’re ready to get started. Take some time to read and learn about the Arduino Uno and be sure you understand the different connections and components. You will also want to install the Arduino IDE (Integrated Development Environment) on the device of your choice so we can write the code that will make our sensor work.

Attach the Buzzer

buzzer.png

The first step is to connect the buzzer to the board. Connect the positive side of the buzzer to any PWM pin. We’ll use Pin 11. Then connect the negative wire into the ground (GND) pin. 

Connect the Jumper Wires

jumper wires.png
microcontroller.png
jumper wire.jpg

Next we will need the sensor and the jumper wires. Connect the red jumper wire to the VCC connection of the sensor. Plug it in gently. Then connect the black jumper wire to the ground (GND) connection of the sensor. Lastly, connect the green jumper wire to the sensor data output (DO) connection. 

To attach the jumpers to the Arduino board we will connect the red jumper to the 5 volt (5V) positive pin. The black jumper will connect to the negative or GND connection on the board and the green jumper wire will connect to the number 7 pin. Be sure your connections are secure and in the right pin locations. 

Attach the USB Cable

laptop and usb.jpg

Now, we want to attach the USB cable to the Arduino board and plug the other end into our computer. We’ll know it’s connected because the red LED (light-emitting diode) on our board will light up. We want to be sure the IDE is installed so we can send the code to the board. The code tells the sensor to trigger the buzzer when motion or movement occurs.  

Write Your Code

ide softwares.png

The code is relatively simple. Take time to understand what is happening and why the buzzer sounds when the sensor moves. The code you will write should initialize the buzzer and the sensor. Once the devices are initialized, we can loop through the data that results from the motion of the sensor. This motion or movement is what makes the buzzer sound. A sensor can convert physical changes into an electrical signal, or data that a computer can process. We are monitoring the sensor to see if anything changes. The changes in our sensor set off the buzzer. 

There are many ways to write code to make our device work. Writing code for the Arduino is not tricky but beyond the scope of this article. To help you get started, look at this Arduino reference guide for writing code. And here are some more code examples that you can refer to. 

Let’s Give It a Try

Once you have everything connected and have written the basic code, we can now test the device. Thankfully, we don’t need an actual earthquake — we can test it by simply tapping or moving the sensor. If the buzzer sounds, we know it’s working. If something isn’t working, be sure to check your code and all your connections.