Earthquake Sensor

Is the boundaries ok??

Strange. I did just that by removing the forwards slashes, but all I hear is static.

#define SPK_HAT   

apart from static, is there any warning signal during an earthquake simulation (when the red led is on)?

no, just static.

Can you please try changing these lines in main.cpp (At line 272):

#ifdef SPK_HAT
  ledcSetup(spkChannel, spkFreq, spkResolution);
  ledcAttachPin(SPK_pin, spkChannel);
#endif

to

#ifdef SPK_HAT
  ledcSetup(spkChannel, spkFreq, spkResolution);
  ledcAttachPin(SPK_pin, spkChannel);
  ledcWriteTone(spkChannel, 0);
#endif

It turns out M5StickC-plus has its own buzzer inside. I did not knew that. I wonder if it creates a problem with the SPK HAT.

Can you try with the above code?

The code seems to work now. I can hear the buzzer go off when the sensor is triggered with or without the SPK Hat plugged in. The static sound is no longer there.

#ifdef SPK_HAT
  ledcSetup(spkChannel, spkFreq, spkResolution);
  ledcAttachPin(SPK_pin, spkChannel);
  ledcWriteTone(spkChannel, 0);
#endif

It seems few hours later after the device is calibrated, the pga bumps between 1-3 as shown in this graph.
The sensor is taped over an electrical outlet faceplate with double sided tape on top of wall close to the ceiling.

Nice to hear that it is workingā€¦

Anything higher than 1g s a serious shake actually. I stick it with heavy duty 3M double on the walll directly. Your case might be one of the following reasons:

  1. Car or truck traffic outside the house?
  2. Once you stick it, because of M5stickā€™s self weight it might move a little until it settles.
  3. I wouldnā€™t recommend it to stick on faceplate since the faceplate can still move if it is not installed firmly.

Maybe It it better to watch it in the long run.

Trucks do pass by with a little rumble but Iā€™m on the 3rd floor.
My faceplate is quite sturdy , no movement when I put slight pressure to slide it.

Before I left the house today , I recalibrate & it has not false trigger after 8 hours. Hope itā€™s still online. The graph shows straight flatline. Will monitor it for a few days.

M5Stickc disconnects from WiFi every 2-3 days , donā€™t know if is related to my WiFi network or the stick itself. Anyhow i added a WiFi reconnect routine to the code in case it loses the WiFi. And i check the online status with this pushover notification automation in HA:

- alias: SeismoM5 Online Check
  trigger:
  - platform: state
    entity_id: sensor.seismom5_state
    to: "unavailable"
  action:
  - service: notify.pushover
    data_template:
      message: >
        SeismoM5 Offline...

Yes, I noticed this as well. Disconnects after a day.

Update: Iā€™ve uploaded the wifi reconnect code, but it didnā€™t auto reconnect. Stays offline indefinitely .

I had my first earthquake today, but sadly the sensor did not triggered. I think the sensor is not sensitive enough. With it mounted on the wall, I tap the wall a few cm close to the sensor but it would not trigger. How to increase the sensitivity?

What was the Richter magnitude and the distance to your location? Do you know it? Did you felt a shake during this earthquake?

To increase the sensitivity, send an MQTT message as follows:

Events: m5seismo/change_pga

Displays or changes PGA trigger value. The first time SeismoM5 works after the first upload, the default PGA Trigger value will be 0.025 g. It can be changed with sending a float value to this topic in raw format, like sending a raw MQTT message 0.050 to m5seismo/change_pga topic to make the trigger value 0.05 g. If the PGA Trigger is ever changed, SeismoM5 saves this value permanently and use it from then on even after you reset SeismoM5. On screen top right corner shows the PGA Trigger value.

  • Check the continuously read pga value first on the screen, Letā€™s say it is always lower than 0.003 g, than i reccommend to send a raw 0.01 message to ā€œm5seismo/change_pgaā€ with MQTT Explorer for example. I am using 0.015 as of now. There has been many earthquakes in my location but they were lower than 4.0 and at least 250 km away. No shakes has been detected here even in high rise buildings.

  • Do not expect this to show earthquakes lower than Richter 3.5 scale earthquakes. And distance to epicenter is also very important.

  • Banging on the wall may or may not work, since as i understand earthquakes occur generally lower than 10Hz frequency and it is best tested on shake tables.

I also am testing this project and will make sure if an earthquake epicenter close to my location (I definitely hope not) happensā€¦

The distance from the epic center to the device was 554km at a mag of 4.7. It happened off the coastline. Although I was not standing near the sensor when the earthquake happened but the next city over, I felt it.

Anyhow i added a WiFi reconnect routine to the code in case it loses the WiFi.

Is this working for you? It does not reconnect after disconnects. Also from observation not sure if it is related, but if the reset button is in the unknown state, the device hast not disconnect. It has been 2 days. Usually for me it has disconnected about a day and somethings several times during the day and it happens when the button state has a timestamp.
2022-12-17_05-57-55

Did you recompiled and uploaded again, after i wrote this message? If not, then you are on the older version with disconnection problem.

Anyhow i added a WiFi reconnect routine to the code in case it loses the WiFi.

Mine has been stable for the last 5 days. No disconnects (or it is reconnecting in case of a disconnect, i donā€™t know). I check the disconnects from the sensor.seismom5_state for how long it is in ā€œLISTENINGā€ mode.

The button ā€œunknownā€ means you have not pressed the Restart button yet. If you press it, than the ā€œUnknownā€ changes to the last date and time you pressed that button. If it is not ā€œUnavailableā€, than it is OK. It wonā€™t affect anything.

Btw we had 6.0 Richter eq 575 km away 3 weeks ago and we didnā€™t felt anything. So i believe those can only be registered with professional grade seismographs from this distance. What we have is only a consumer grade accelerometer.

Did you recompiled and uploaded again, after i wrote this message? If not, then you are on the older version with disconnection problem.

I thought I recompiled. Will do it again today.

What we have is only a consumer grade accelerometer.

I definitely felt it when it happened. I will need to change the pga. I have tried using your suggestion, but it didnā€™t work. Maybe I did it incorrectly??
I have changed the topic to house/m5seismo btw.

Ha:

mqtt explorer:
2022-12-17_07-45-20

Sorry, you need to change pga_trigger, not change_pga. I forgot update the documentation. Change_pga is not being used anymore.

Did you recompiled and uploaded again, after i wrote this message? If not, then you are on the older version with disconnection problem.

Very strange. I have rebuilt the code and to make sure it has complied the new code, I have changed the topic name. The new topic name has taken affect, but when the device disconnects, it will not reconnect.

After 7 days of stable working, mine also disconnected yesterday, and couldnā€™t connect back. Will look into it. Btw, the MPU6050 is much more reliable and sensitive comparing to MPU6886 in my tests. So maybe i will also look for an external MPU6050 connection to try.

i will also look for an external MPU6050 connection to try.

Something like this??

For the wifi disconnect issue, Iā€™ve changed line 315 from this

while (WiFi.status() != WL_CONNECTED)

to this.

  while (WiFi.status() == WL_CONNECTED)

It has been 2 days and no disconnect. However, if the device loose wifi connection to the router, mqtt stays offline.

while (WiFi.status() == WL_CONNECTED)

This change is not relevant; this line only prints ā€œ.ā€ to serial until WiFi connection. So it will have no effect on WiFi disconnects.

I am trying ESP32.reset now instead of Wifi.reconnect for WiFi disconnects, will see if it worksā€¦ I also gave it a static IP. Letā€™s see if it will reset the m5stick in disconnects.

I also enlarged the PGA number on screen as follows:

The coordinates might be weird in your plus stick, if it is, then send me a picture so that i can correct it.

Additionally i changed some init code of the MPU6886 in the hopes that it will have lower noise but it looks like it didnā€™t affected much. If you want to try, the changes are uploaded on github; or you can wait for the results of the WiFi discconnect problem.

Something like this??

Yes, maybe i can use a proto board like this or better like this if i can fit the MPU6050 in these. I prefer the second one since it will be away from the stick and will be less affected from the electromagnetic noise.