Introduction
Earthquakes pose a threat to a third of earth’s population. They kill more people than all other types of natural disaster put together[1].
Lives could be saved by providing an early warning of an impending earthquake. Systems exist for this purpose but they tend to be expensive. Some systems detect the arrival of less destructive P-waves before the destructive S-waves arrive. A method which would provide more warning would be for sensors at the epicentre to provide a warning to people further away.
Earthquake waves travel through the earth at approx. 6000kms/hr. Therefore a built up area 100kms from the epicentre may have up to 1 minute’s warning. This may be sufficient to allow people to move to safety and for critical systems to be shut down.
It’s beneficial to have sensors as close to the epicentre as possible so that as much warning can be provided as possible. This requires a large number of sensors distributed over the earthquake zone and connected over a low latency network to servers which determine whether an earthquake is occurring. Similarly, it requires a low latency method of alerting people that they need to take action such as moving to safety.
In order to achieve thi aim the sensing device needs to very low cost so that large numbers can be deployed. This project has created a prototype using a low cost sensor with the esp8266. It uses an analogue sensor which is sampled by the esp8266’s 10-bit ADC. It connects to Cayenne. If the device triggers a pre-determined threshold Cayenne generates an SMS warning of an earthquake.
Since an earthquake is normally a fairly rare event the software has been written to send a 10 second 'heartbeat' to Cayenne in order to provide confirmation that the device is still functioning. This heartbeat reports the time since the device was last powered up. Cayenne alerts have been set up to report an earthquake by SMS.
Measurement of Earthquakes
There are several types of measures of earthquakes. The Richter scale measures earthquake intensity. Peak ground acceleration and peak ground velocity are often also recorded. Peak ground acceleration is believed to be well correlated to damage to buildings especially during earthquakes[2].
For this project acceleration will be measured using an Analog Devices accelerometer. The ADXL335 has a sensitivity of 300mV/g. The sensor bandwidth is set using a capacitor. On the Kitronik breakout board the capacitor is 100nF which sets the bandwidth as 0.5Hz to 50Hz.
The table provides details of how the US Geological Survey relates acceleration and earthquake intensity. The voltage generated by the ADXL335 under these acceleration conditions and the expected peak ADC response has been calculated.
Compared with the expected acceleration during ‘strong’ earthquakes the sensor does not generate a significant peak output (28-54mV). The sensor output would benefit from some amplification. However, the priority is to detect the strongest earthquakes causing the most damage and risk to life.
Hardware Design
esp8266/ADXL connectivity
To simplify the build the ADXL335 and the esp8266 are provided on breakout boards. A nodeMCU board contains the esp8266. Kitronik provide a convenient break-out board which has the chip scale-packaged ADXL335 mounted on it. The board provides convenient connections to power and the 3 analogue outputs. Use of the nodeMCU also simplifies esp8266 programming and power supply which is through the USB interface. The connection between the nodeMCU and the Kitronik breakout board is a simple 3 wire interface (power, GND and analogue sensor output). The ADXL335 requires a supply voltage in the range 1.8 to 3.6V which the nodeMCU can supply. The Z-axis sensor output is connected to the A0 port of the nodeMCU/esp8266.
Since the esp8266 only has one ADC the Z-axis (vertical) output is the only one to be sampled. A future version of this project may have an external ADC so that all 3 axes can be sampled ensuring that the peak earthquake motion in any direction is measured.
The power comes from a mains USB PSU.
Enclosure
The two break-out boards are contained in a simple low cost enclosure.
The enclosure requires a small amount of modification to provide entry point for the USB cable providing power. Using a small file a small semi-circle is created in the plastic.
The boards are mounted in the enclosure using double-sided tape. The nodeMCU is mounted on the lid whilst the sensor board is placed in the base. A more robust but permanent attachment method would be to glue them to the enclosure.
The enclosure itself needs to be rigidly mounted on a solid surface. Since the z-axis of the sensor is being sampled the enclosure must be horizontal to detect motion in the vertical axis. The ideal place to mount the sensor is on a solid wall or on hard floor surface.
Software Design
The Arduino IDE has been used for this project.
To use the NodeMCU with the Arduino IDE it is necessary it add this to the ‘Additional Board Manager URLs’ under Preferences in the IDE. Details can be found here. http://www.instructables.com/id/Quick-Start-to-Nodemcu-ESP8266-on-Arduino-IDE/
Running Average library
The sampled data is used to calculate a running average. This is the mid-point of the sensor output at approx. 1.65V.
A RunningAverage.h library is used for calculation of the running average. This has been created from Rob Tillaart’s running average. This describes the usage of the library. It is attached as a .zip file to this project which can be added to the Arduino IDE under Sketch, Include Library, add .zip to library.
Calculation of acceleration
The deviation from the running average is a measure of the acceleration. The sum squared is calculated so that the absolute value of acceleration is calculated rather than a positive of negative deviation from the running average.
Earthquake detection
To determine whether there is an earthquake the average of the sum of square differences is calculated approx. every 48ms. This duration is determined by the variable numsamp (12) and the delay (4ms). The delay roughly controls the sample rate (approx. 250samples/sec). If the average sum of square differences calculated during each 48ms period exceeds a pre-defined threshold then the counter ‘abovethrcnt’ is incremented by one. The threshold has been set to detect ‘strong’ earthquakes (>0.092g)
The average sum of differences is repeatedly calculated until lastmillis is greater than reportingint. Reportingint defines the reporting interval which is set to 10000 milliseconds.
Posting to Cayenne
The Cayenne MQTT library must be added to the Arduino IDE in order to post messages to Cayenne. The Cayenne MQTT is described here. This project is based on the example provided with the library.
There are 3 channels. These are:
- lastMillis - time in milliseconds since last power up
- abovethrcnt - number of 48ms windows in which the earthquake threshold was exceed
- earthquake/no earthquake
If abovethrcnt exceeds 52 at the end of the reporting interval then an earthquake will be reported to Cayenne by setting channel 3 (earthquake alert) to the value 2. If the abovethrcnt does not exceed 52 then channel 3 is set to zero. The number 52 corresponds to 25% of the 48ms windows exceeding the threshold during the 10 second reporting interval. When the value of this channel changes from zero to two a trigger generates an alert and sends an SMS to warn of an earthquake.
Summary and further work
This project is a first step in creating a distributed low cost earthquake monitoring system. It has demonstrated that a sensor can be made at very low cost. Cayenne has made it possible to quickly prototype a demonstration system.
It will be necessary to determine the sensor’s susceptibility to false alarms. By aggregating the inputs from many sensors in an area it will be possible to significantly reduce false alarm rates to localised vibrations such as heavy vehicles or nearby construction works. Cayenne would need to be extended to create rules of a type that generates an alert if x out of y sensors generate a trigger within time period t.
The device will be required to report its location so that a centralised data aggregation system can determine the epicentre of an earthquake. The warning system can provide recipients with an indication of the time until the earthquake waves reach their location and potentially an indication of its intensity.
It’s likely that some form of short term battery backup (or supercapacitor) will be required to provide power in the event of power loss. This may also include an uninterruptible power supply to WiFi routers/modems.
[1] The Human Cost of Natural Disasters 2015, Centre for Research on the Epidemiology of Disasters
[2] http://www.wbdg.org/resources/seismic-design-principles
Comments