Earthquake Sensor

Hi. I am using the draft version. Can you confirm if pressing the reset or calibration button via the gui or the rest button in HA actually performs a reset/calibration on the device? The states changes when I view it on mqtt explorer but stays on REST or CALIBRATION state depending on what I pressed. I didn’t look at the device itself, but I think it did nothing.

Also, how are you simulating an earthquake without waiting for an actual earthquake to happen? There was one last night, but the device did not trigger. It was set at default value of 0.25 atm.

Update: Just noticed you have made changes 4 hours ago. I have not updated to this version.

Hey @duceduc , in the previous draft version i forgot to change the state to LISTENING after a CALIBRATION or RESET, so it stayed as calibration even though it was really listening.

Yesterday i uploaded a new version on draft branch, corrected that one and numerous other items including an improved calibration. Normally you need a shake table to simulate an earthquake but i have no access to those so i use a shaky dinner table instead of a seismic shake table :rofl:

0.25 pga stands for a moderate to high earthquake, normally i check pga graph for 1 day and after seeing its usual pattern, i use around 0.0100 pga. If you get fake triggers at that value then use 0.0150 pga and increase it with 0.0050 until you don’t get a fake trigger.

After 15:00 i used the new draft branch version, you see it stays under 0.0080 but this graph shows pga every 30 seconds, so there might be values over 0.0080 in between, that’s why i use and test 0.0100.

After 15:00 i used the new draft branch version, you see it stays under 0.0080 but this graph shows pga every 30 seconds

One of my sensors is doing quite well. Pretty same as yours and has still below .008. However, I have another sensor which spikes abve .010 every so often. It maybe where I have placed it for testing, but I don’t think so. Just to be sure, I will place it at the spot where it will eventually go and view the results after a day.

Regarding the speaker, I have enabled the speaker and noticed it is constantly emitting static audio sound even before the threshold pga. Can this be fix where it only turns on when above the threshold??

Regarding the speaker, I have enabled the speaker and noticed it is constantly emitting static audio sound even before the threshold pga. Can this be fix where it only turns on when above the threshold??

In fact, the buzzer is set only to turn on when it exceeds the threshold. Otherwise it sends “0” to buzzer which means shut down…I do not have that static in my installs on both StickC and Plus versions. Are you using SPK HAT or the internal buzzer of M5StickC Plus?

The first implementation of Master/Slave configuration is on the draft branch for tests:

Master / Slave Configuration for more reliable triggers

Although MPU6886 on M5StickC is not very much noisy, once in a while, the pga jumps for 5-10 seconds above trigger (frequency is like once or twice every 1-2 days, up to 0.0150 g according to my results). So i also added a Master/Slave Configuration which requires two M5Sticks. If the Master stick triggers an earthquake, it also checks the Slave Stick and if it also has a trigger, then the Master changes its state to “EARTHQUAKE” only then…

Configuration:

  1. In order to upload “SLAVE” first, uncomment “//#define SLAVE” and make it “#define SLAVE” in config.h file.
  2. Upload the SLAVE M5StickC. The SLAVE is ready.
  3. Comment the “#define SLAVE” line back to “//#define SLAVE” in config.h file.
  4. Upload the MASTER M5StickC.
  5. Go to the Web Page of MASTER M5StickC.
  6. Check “Master” checkbox and save it. If you don’t check the “Master” checkbox on web page, this stick will still act as a standalone SeismoM5.
  7. Just check the /state of MASTER Stick for earthquakes, not the SLAVE!

Although MPU6886 on M5StickC is not very much noisy, once in a while, the pga jumps for 5-10 seconds above trigger (frequency is like once or twice every 1-2 days, up to 0.0150 g according to my results).

This sounds like how my M5StickC is behaving. The Plus stays well below .008. Will try the new update when I get the chance.

I pray for all the lost souls in Kahramanmaras Earthquake in Turkey, may all 20.000 people rest in peace…

All the survived people there are now fighting with the cold outside, the 7.7 earthquake just hit at 04:17 when all people were sleeping at their homes, and the second 7.6 (Not an aftershock, another one very close to the first epicenter) at 13:24. This is the second big earthquake that hit my country Turkiye in the last 24 years… We all mourn for all our brothers and sisters there.

Almost all are the victims of collapsing buildings.

FYI the earthquake was 1.000 km away from my location, it did not catch anything as far as i see but that’s normal for a consumer grade accelerometer i suppose, it is not an industrial seismometer.

Please keep your prayers for all the people suffering there…

AKUT Turkish Search and Rescue Platform Donations

AHBAP Voluntary Organization Donations

AFAD Government Disaster and Recovery Earthquake Humanitarian Aid Campaign

Turkish Red Crescent:

I feel their pain and know exactly what is going through their minds as I have experienced the Japan 3/11 earthquake. I still know exactly what I was doing when it hit to this day.

I have setup to get notifications of any earthquake that is over 4.0M. I saw this a few days ago on my phone notification and thought it was an error.

1 Like

I installed 2 sticks side by side powered by two different power sources. One of them is installed by a heavy duty double sided tape (it is like 1-2 mm thickness, that will definitely absorb some of the vibrations), and the other with the self magnets of the stick (Not recommended, they are weak). But i get this interesting result:

Looks like the spikes occuring from both sticks fit, they do not seem random but noises from the outside, like passing trucks or something. I put the PGA trigger to 0.0150 and it works well without false triggers. Graphs show 10sec update periods.

Btw, worked on a little bit more on stability of the IMU, calibration and display graphs and information. The new code is in draft branch as usual.

Here is my results. I have 1 C and 1 Plus sticks. The C seems to pick up alot of noise than the Plus. Also, my microwave is triggering both the devices as seen by the graphs bleow on different days in red boxes. It does not happen all the time when the microwave is on and it does not constantly spike high for the duration of the time the microwave is running. Just initially when the microwave is turn on.

During the day, when everyone is not at home, I do not get false postive triggers. However, the seismom5_pga (C stick) spikes above 0.010 quite frequent and at random while the seismom5p_pga stays below 0.08.

2/14/2023

2/16/2023 (this graph triggered on 6pm and 4:30am. both time the microwave was being used)

Wow, great findings, thanks a lot @duceduc. I got 2 new Cplus sticks so i will be able to test these also.

The issue with the microwave is really interesting. I really don’t know if it is related to the power source-adapter of the stick is in the same power line-fuse line with the microwave in the house and the microwave draws a high current from the power line on when you just power it on. This might cause a wave in the power of the stick adapter. This is just a theory, so i am not so sure. You can test this theory with feeding the stick with a 5.000 or 10.000 mah smart phone power bank. 10.000 mah can feed the stick for about 48 hours.

That reminds me to also include temperature compensation for the accelerometer values, the MPU has a built in internal chip temperature measuring, which causes the gyroscope and accelerometer values to drift, when the temperature changes.

Thanks again for the great findings and help…

I really don’t know if it is related to the power source-adapter of the stick is in the same power line-fuse line with the microwave in the house and the microwave draws a high current from the power line on when you just power it on.

A little more details on my 2 stick setup. The Plus is in a different room from the microwave. So I would have to assume the power line is not being share with the microwave. In fact, this power source the Plus is connected to is suppose to be for an A/C unit which we did not install.

The C stick is in same area as the microwave and it may be sharing the same line as the microwave. The pga is currently set at 0.010 for both sticks. No actual earthquake has occured so I can’t say if 0.010 is a good starting point, but it was lower than my previous pga setting.

From the early version of the code, I mentioned that my sticks would loose wifi after a day or so. I setup an automation to reset every day at midnight. It didn’t help as much as it was still loosing wifi. Using this same technique todo a reset once a day or a few days after maybe will help with the drifting? It appears to be more stable after a reset. Just a thought.

From the early version of the code, I mentioned that my sticks would loose wifi after a day or so. I setup an automation to reset every day at midnight. It didn’t help as much as it was still loosing wifi. Using this same technique todo a reset once a day or a few days after maybe will help with the drifting? It appears to be more stable after a reset. Just a thought.

Just to confirm some things with the disconnection issues:

  1. seismoM5/status “online” or “offline” only stands for MQTT connection, not WiFi. Sometimes there may be issues on connection like the SeismoM5 disconnects from MQTT Server for whatever reason, but the WiFi may still be on.
  2. If you want to change the behavior of M5Stick to restart instead of trying to reconnect on WiFi disconnects, you can change the following lines in the main.cpp code:
    case WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
      logln("WiFi Disconnected. Restarting...");
      stopMqttTimer();
      xTimerStart(wifiReconnectTimer, 0);
//      delay(3000);
//      WiFi.setAutoReconnect(true);
//      ESP.restart();
//      WiFi.reconnect();
      break;

change it to:

    case WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
      logln("WiFi Disconnected. Restarting...");
//      stopMqttTimer();
//      xTimerStart(wifiReconnectTimer, 0);
      delay(3000);
//      WiFi.setAutoReconnect(true);
      ESP.restart();
//      WiFi.reconnect();
      break;

When you make this change, if the M5Stick loses WiFi connection, it will simply restart the SeismoM5.

  1. My M5Stick was connected to WiFi for 6 days straight without any problem, yesterday night i had a disconnection, when i checked out the reason, i realized the wireless WiFi bridge i use on that floor happens to be disconnected from the main router so there was no WiFi in that floor for 5 minutes. So, the problem was not because of M5Stick disconnect, but from the networking equipment. So, that could also be a reason?

The pga is currently set at 0.010 for both sticks. No actual earthquake has occured so I can’t say if 0.010 is a good starting point, but it was lower than my previous pga setting.

I keep now the PGA as 0.0150 g. There are no false triggers for some time. With 0.010 i still get 1 or 2 false triggers per day. Of course it depends on the noisy environment.

From the recent Kahramanmaras-Turkiye earthquake videos, i realized again once a strong earthquake hits, the electricity power lines are the first to be affected, So people have only 4-5 seconds to activate electricity activated devices, like rollers, locks, gas valves etc. The first seconds are very critical in that sense. SeismoM5 might create a big difference related to this risk.

Using master/slave installation with STA/LTA method seems more logical to use, i will start testing that kind of installation next week.

Changed the WiFi and MQTT disconnection recover method with a much more simpler one. The code checks the WiFi and MQTT on loop() 10 times every second, instead of onwifievent(). Reconnection and wait times are also solved in a simpler way. Hope this will solve the disconnect problems…

It is in “beta” branch on the github.

One thing i realized now is, on wifi disconnects and reconnects, the accelerometer values create a peak of around 0.0150 for 2-3 seconds. This was happening in previous reconnection method and also with this new one. As i understand, the wifi methods interfere with the accelerometer values. Maybe because the chips are very close on the PCB… Most of the times this doesn’t register as an earthquake since the wifi is lost anyhow. Other times, there seems no problem.

Found out the weirdest bug, it is either on asyncmqtt or on espasynctcp.

Normally, during an earthquake trigger, SeismoM5 starts publishing MQTT pga values 10 times per second, even after the earthquake detrigger it publishes 4 seconds more to be on the safe side or to measure if the S waves come. However,when it starts publishing 10 messages per second, the accelerometer readings go haywire and the values are higher than they should be in reality. This affects especially the STA/LTA method, it brings a lot of fake triggers. This is the result under asyncmqttclient publish like this:

The blue ellipse is just one knock on the table. Goes up and down, and the vibration ends there. However the green ellipse part is the period where the code sends the publish messages, they should normally be down and silent like this:

This second graph values are from the same code, the only difference is i commented out the asyncmqttclient publish mqtt command. If i use pubsubclient it also gives the correct values.

pubsubclient brings more disadvantage, so to use it is out of question. So i started testing everything i could think of. Lastly, i tried decreasing the 10 publishes per second to 5, and this seems to be working fine. I think sending 10 messages in 1 second creates a problem on the TCP and buffers, i really don’t know why. But i changed it in the code in the “main” branch, so you can test it if you like…


This is 5 messages per second instead of 10…

just ordered my M5stickC - Being based in NZ I can see the value of this, awesome work and thank you @febalci

1 Like

Hello @febalci, I made all the settings you gave, but. There is a shortcoming that I could not run the system.

Merhaba @febalci verdiğiniz bütün ayarları yaptım fakat. Bi eksiklik var ki sistemi çalıştıramadım.

Success…now to test it. I have set my limit to 0.08 as this is classified as a 3.0 and higher quake. We get lots of small quakes her in NZ and 3 and up is my concern

1 Like

I think you meant to say 0.008g instead of 0.08g. Yet, 0.008 is still in the boundary of the acclerometer natural noise levels, that means it will give fake triggers with 0.008g. I personally use 0.0150g, i suggest you use something between 0.0120 to 0.0200g.

Btw, there is a nice article here: Accelerometer mounting best practices. Double sided adhesives, if they are thick, can absorb some of the vibrations; but i am still using this type. Also, saince you are in NZ, you might have experiences eqs earlier, you can mount your stick to a more vibration zone medium instead of the wall itself, like a wall supported shelf maybe… Since in sm aller eartrhquakes the concrete walls might stay stable, but a floor stand long light might swing back and forth during the same eaqrthquake. These are just ideas, i am now testing my sticks; one of them is supported to a wall hanged TV set, and the other is mounted on a floor stand long marble night stand.

1 Like

I am currently set at 0.0100 for both. One stick does go over 0.0100 quite often while the other stays below 0.0100. I think it is still too high as I wish to have it alert me when the wall shakes even if the epicenter is not near me. Maybe it is impossible for this particular grade device? .

I have tried setting to 0.008, but I am getting false triggers.