EveryCircuit
Contact
Reviews
Home
crake
modified 7 years ago

Earthquake detection for Arduino with code

1
0
149
01:31:17
Requires a geophone. Tested this with an Arduino Uno. It works pretty well for a single supply amp. The opamps are powered using the UNO's 5V pin and GND. Output from the amp is measured using any two of the UNO's analog pins, and solving their difference. During testing I was able to measure vibrations through a concrete slab from both jumping and then returning to the ground, approximately 1 foot from the geophone. Returning to ground was detected as far away as 10 feet, but I haven't tested any further than 10 feet, yet. It should be noted, the concrete slab is incredibly thick as it is located on the bottom floor of a 7 story building. //Arduino code. //This should get anyone interested started. int pinPos = 0; int pinNeg = 1; float vPerBit = 0.0048875855; float gain = 130.0; //Even though the gain in this simulation is set to 150V/V, the one //that was tested in real life was approximately 130V/V. void setup() { Serial.begin(115200); pinMode(pinPos, INPUT); pinMode(pinNeg, INPUT); } void loop() { if(Serial.available() > 0) { int dump = Serial.read(); float vPos = analogRead(pinPos)*vPerBit; float vNeg = analogRead(pinNeg)*vPerBit; Serial.print(millis()); Serial.print(" mS, "); Serial.print(((vPos - vNeg)/gain), 8); Serial.println(" V"); } } #Python code. #If you want to save output from the #geophone to a file, this is a simple way #of achieving that... import serial import time import webbrowser arduino = serial.Serial('/dev/ttyACM0', 115200) time.sleep(3) outputFile = open('output.csv', 'w') try: while True: arduino.write(b'1') output = arduino.readline().decode() output = output.strip('\n') outputFile.write(str(output)) print(output) except KeyboardInterrupt: arduino.close() outputFile.close() webbrowser.open('output.csv') print('Goodbye') exit() If anyone would like to improve this, have at it. It is just a start. It could be a quick means of getting a homemade intruder alert, or basic earthquake sensing system up and running. For greater resolution, use a better ADC. The UNO ADC is only 10 bit. Most serious seismograph systems use 24 bit ADC's.
published 7 years ago

EveryCircuit is an easy to use, highly interactive circuit simulator and schematic capture tool. Real-time circuit simulation, interactivity, and dynamic visualization make it a must have application for professionals and academia. EveryCircuit user community has collaboratively created the largest searchable library of circuit designs. EveryCircuit app runs online in popular browsers and on mobile phones and tablets, enabling you to capture design ideas and learn electronics on the go.

Copyright © 2025 by MuseMaze, Inc.     Terms of use     Privacy policy