Main Content

SeismoM5 Earthquake Sensor

An MQTT Earthquake Seismc Sensor with M5StickC and SPK HAT

Living in a highly seismic activity city brings its own challenges. Waking up in the middle of the night with a shake and wondering the epicenter and magnitude of the earthquake, praying that everyone you love is safe etc. You start browsing through each of the Seismology networks to get a little bit more knowledge about it but you have to wait at least some minutes to get some reliable information about this specific earthquake.

Having a smart home with lights, rolling shutters, lots of sensors, actuators etc., an earthquake sensor was the missing piece. If only there was an affordable sensor which will activate during an earthquake and gives audio and visual warning, shut off gas valves, open some doors, rolling shutters and lights for a safe escape route. A professional or amateur grade seismograph or structural vibration sensors were out of question for me since I am nowhere near being a seismologist or do I have the time to analyze the output of these sensors. So I came up with an amateur idea of using M5StickC in use.

SeismoM5 is an Earthquake Sensor Implementation on M5StickC, using its own MPU6886 accelerometer. Although MPU6886 in M5StickC is a bit on the noisy side; disabling Gyro and using an accel calibration helped a little. The properties of this project is:

- Calibrate MPU6886 accelerometer and use calibration results as offsets.
- Use DLPF - 5 Hz.
- Use MQTT and send data, only when an earthquake happens.
- Draw X, Y, Z accel results on M5stickC screen as graph, only when an earthquake happens.
- Show PGA always.
- Emergency alerts; Red Led and SPK HAT sound warning during an earthquake.

I am nowhere near being a Seismologist or I understand anything about. It is just that I live in an overly active Seismic zone. The idea came up for adding an earthquake sensor to the smart home; to shut gas valves off and open some rolling shutters for an escape route during an earthquake.

So I tried some signal algorithms to get the most effective earthquake trigger mechanism possible. Among these, STA/LTA method was very close to get rid of the noise and unwanted man made noises and peaks. However, the test results were not succesfull for me. So I opted out for a simple PGA calculation:

pga = sqrt(x_vector_mag * x_vector_mag + y_vector_mag * y_vector_mag + z_vector_mag * z_vector_mag)*scale_factor;

The triggering mechanism is, if PGA exceeds limit, that is an earthquake. PGA gives intensity too, but I do not know how reliable that is.”

Link to article