Piezoelectric sensor earthquake GIGA R1

Hello,
I'd like to use my piezoelectric sensor to detect earthquakes on my Arduino GIGA R1 WiFi. For that I have this code that I call every 20 ms with a millis in my loop. Besides the fact that my sensor has “noise”, I would like to know if it was possible to create a concordance between my mV data and a result on the Richter scale?
Thanks in advance

#define SENSIBILITE_CAPTEUR 100.0 // Exemple : 100 mV/g

void setup_piezoelectrique() {
  pinMode(piezoPin, INPUT);
}

void get_piezoelectrique() {
  CapVal = analogRead(piezoPin);
  CapVolt = (float)CapVal * 5.0 / 1023.0; // Conversion en volts (5V référence, 10 bits ADC)
  float CapMilliVolt = CapVolt * 1000.0; // Conversion en mV

  if (CapMilliVolt < 0) {
    signalerErreur("Piézoélectrique", "Lecture du capteur échouée !");
    return;
  }

  // Conversion de la tension en accélération (g)
  float acceleration = CapMilliVolt / SENSIBILITE_CAPTEUR;

  // Estimation de la magnitude du séisme (relation empirique)
  float magnitude = round(log10(acceleration) + 3.0); // Exemple de relation simplifiée

  Serial.print("⚡ Piézoélectrique : ");
  Serial.print(CapMilliVolt);
  Serial.print(" mV, ");
  Serial.print("Magnitude estimée : ");
  Serial.println(magnitude, 2);

  // Enregistrer uniquement si la tension dépasse le seuil
  if (CapMilliVolt > PIEZO_THRESHOLD) {
    String logMessage = "⚡ Piézoélectrique : " + String(CapMilliVolt) + " mV, Accélération : " + String(acceleration, 3) + " g, Magnitude estimée : " + String(magnitude, 2);
    ecrire_log(logMessage);
  }
}

I'm not very convinced you can do it.
The acceleration measured by a piezoelectric accelerometer and the magnitude of an earthquake (measured on the Richter scale) are two independent values, which cannot be directly converted into each other. If you want to correlate the acceleration measured by a piezoelectric accelerometer with the magnitude of an earthquake, you need to use more complex analyses, such as those involving seismic data and seismic models, to establish the correlation between the two. It looks like it isn't just a matter of a (logaritmic) conversion function.

I also believe that the quality and sensitivity of Arduino's analog-to-digital conversion does not allow for sufficiently stable and precise measurements unless a relatively strong earthquake occours.

OK, thanks.
How do seismographs work in this case, isn't there a way to get a more “understandable” value of my piezoelectric instead of just voltage then? Anything, as long as it's easier to understand and interpret I'm in.
Thanks

I'm not an expert in seismology, however as far as I know seismographic devices use specific quality sensors, I hope you are not considering using the small piezoelectric disks (the ones used to emit sounds or to detect vibrations like in electronic drums).
Piezoelectric sensors, particularly Integrated Electronics Piezo-Electric (IEPE) accelerometers, are used for precision measurements of smaller, higher-frequency seismic events, here (just an example) you can find more information about that.

Furthermore, it is not enough to acquire the voltage value, but it is necessary to perform an analysis of the data coming from the sensor, starting with filtering the data based on their frequency (at least through FFT) over a specific time range, and examine the peaks to calculate their equivalent energy.

As far as I can tell, it is not only a problem of sensor quality, but also of relatively complex data processing (there are sensors that integrate some active circuits to pre-process the data), and finally of the quality of the analog-to-digital conversion of the Arduino itself (together with the quality of the cables and connections).

I don't know if this project is for any particular purpose like a school assignment or demonstration, however I hope I haven't discouraged you, but I still believe that detecting simple vibrations with a sensor is one thing, while calculating the energy in the Richter scale is much more complex than I, as a non-expert in the field, can imagine.

If it's just for demonstration or educational purposes, surely you can do something but don't expect to get very realistic or scientific data. Hope it helps!

PS: some more technical information about vibration analysis can be found googling around, for example from a CERN paper:

The initial aim of this project is to detect earthquakes, because my sensor will be installed in my company's server room, and when too much vibration is felt, the mobile phone connected to the arduino will send me an alert. Thank you very much for your answers. I think I'll stick to my voltage and set a limit value by hand. I'll show you a picture of my sensor but I don't think it's designed to detect earthquakes but rather vibrations in general.
If you have any last ideas to pass on to me, I'm here, otherwise I'll stick to this.
Thanks again.

Most people use moving magnet and coil detectors for earthquake detection, as they are much, much better at picking up low frequency signals.

Earthquake vibrations have frequencies in the general range of 0.1 to 10 Hz, whereas a consumer grade piezo like you show is most sensitive to signals in the range of 1 to 10 kHz.

An inexpensive, Arduino compatible geophone and SeismicStream interface can be purchased from Mindsets UK, and are similar in sensitivity and response to the popular but much more expensive RaspberryShake. Mindsets also sells a couple of complete kits.

Yes, it's a standard piezo, the one commonly used for either (passively) play tones or to detect vibrations (I used it in an electronic drum set). I never searched for its specifications, but I don't think it's a good idea, it couldn't be sensible enough to be able to capture and correctly recognise small vibrations from a relatively low earthquake. So the only way is to test it in various conditions, but I don't know how you could simulate a "realistic" small earthquake to test it with, it could be a tough job or bringing to wrong thresholds. Give it a try...

Just to add my last 5 cents, consider eartquakes vibration can be jolting (vertical) or undulatory (horizontal) or a mix of them depending on the epicenter of the earthquake (relative distance and position) so you should think about using a couple of perpendicular sensors and analyze both...

PS: In any case you always need a good and specific filtering (you don't want subway or trucks vibrations alerting you every time, don't you?:wink: )

Ok that's fine thanks ahah.
My goal is to detect “only” earthquakes of magnitude 3 or more. So that's why I wanted to set the alert threshold high enough so that slamming doors wouldn't alert me for nothing lol.
On top of that, it has strange peaks from time to time when no vibration was present (unless it's so powerful that it detects the deepest earthquakes ahahah).
Your information has helped me a lot, thank you very much. I'll see what I can do with it.

Ok ok I didn't know, this is super interesting!
You really want to discourage me ahah (just kidding of course).
Thanks a lot!

Well, I'm sorry to say, but for me it's still unfeasable, or at least it is not reliable enough for the intended goal, too many variables cound give you false alarms, or, worse than that, missing alarms

Apart from the above issues (the need for at least two sensors, analyze the signals in a sufficient time interval, and do a Fourier analysis..) an R3 or more could be more easily detected using an MPU6050 accelerometer instead of that piezo buzzer, or using something like pendulums, see those examples like this or this one.

Anyway, let me say the ancient Chinese had already realized it centuries ago, and without any Arduino: :smiley:

Inquiring minds have to ask why you need to be notified? The quake has already happened. Why not subscribe to a web site that keeps track of earthquakes?

Yeah, too complicated for the stuff I've got at my disposal. Well, project aborted, but thanks again to the 2 of you for passing on this very important information. Keep it up!

It's to be able to intervene on site when I'm working from home, for example. I don't live 4 hours from my place of work, but I figure that if an earthquake hits right where I work (unluckily) and I don't feel a thing at home, at least I'll know about it. But it's true that tracking seismic activity on the Internet is pretty cool, but I'd still have to be able to implement it in my arduino...

I don't know if this is going to work but don't forget that you are sampling a wave that's positive half the time and negative half of the time and it crosses through zero twice per cycle. The raw readings will "look random".

Every 20ms should be fast enough but you'll need to find the peaks or average the positive values or the average of the absolute values.

The Arduino can't read negative voltages. If you don't bias the signal the negative readings will be read as zero.

Negative voltages can potentially damage the Arduino but as far as I know, a piezo sensor by itself can't put-out enough current to do any damage.

Based on DVDdoug analysis, I would use two small signal diodes to create a full wave rectifier. Watch the positive voltage level with your Arduino. When above a set level, alarm!

I strongly encourage you to experiment with detecting earthquakes, and would be very interested to learn if you can figure out how to do that reliably using a piezo disk as the sensor.

It's the word “reliably” that gives me trouble ahah

I don't have exactly that, but the principle is similar: as soon as the voltage sensed by my piezo is higher than the one I've set, the alarm goes off. Is that what you're talking about?

As long as your Arduino is only presented with positive voltages to ground, you are ok.

A piezo disk as in post#5 can detect low frequencies, depending on load resistance.
Fom memory you can detect >100Hz with a minimum load resistance on 1Megohm.
Below 10Hz would require a load (resistor) of several 100 Megohm. And that's electrical, without the mechanical challenges. The force must bend the centre of the disk, while keeping the edge ridgid.
Leo..

1 Like