Skip to content

Instantly share code, notes, and snippets.

@fmotta

fmotta/README.md Secret

Created October 5, 2015 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmotta/7f48add67544ccdf4fc9 to your computer and use it in GitHub Desktop.
Save fmotta/7f48add67544ccdf4fc9 to your computer and use it in GitHub Desktop.
Simpler Earthquake Monitor

I started with the flow from deecjay and found it did not work for me.

So, I started anew:

Gets the earthquake report from USGS (all within the last hour) - and creates one message per quake with time, lat, lon, depth, magnitude, place and type (may not be an earthquake - but you can fix that).

The particular feed used is http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.csv there are plenty of others to play with - see http://earthquake.usgs.gov/earthquakes/feed/v1.0/

Sample message: { "time": "2015-10-05T03:13:25.000Z", "latitude": 60.2236, "longitude": -141.066, "mag": 1.4, "place": "77km ENE of Cape Yakataga, Alaska", "type": "earthquake" }

[{"type":"tab","id":"29609aca.d69f66","label":"USGS Earthquake Monitor"},{"id":"16616712.e99e99","type":"mqtt-broker","broker":"localhost","port":"1883"},{"id":"a9ecfe6f.5613","type":"http request","name":"","method":"GET","ret":"txt","url":"http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.csv","x":276,"y":54,"z":"29609aca.d69f66","wires":[["86781b39.7987e8"]]},{"id":"66f14749.990eb8","type":"debug","name":"","active":true,"complete":"false","x":619.0000610351562,"y":265.9999694824219,"z":"29609aca.d69f66","wires":[]},{"id":"cc40789.f33bf88","type":"inject","name":"","topic":"","payload":"","payloadType":"date","repeat":"300","crontab":"","once":false,"x":92,"y":53,"z":"29609aca.d69f66","wires":[["a9ecfe6f.5613"]]},{"id":"3bb724f.fc448dc","type":"function","name":"USGS Quake monitor Strip Disinteresting Data","func":"//node.warn(msg.payload);\n// \"time\", \"latitude\", \"longitude\", \"depth\", \"mag\", \"magType\", \"nst\", \"gap\", \"dmin\", \"rms\", \"net\", \"id\", \"updated\", \"place\", \"type\" \nvar out = {};\n\nif (msg.payload.depth) delete(msg.payload.depth);\nif (msg.payload.nst) delete(msg.payload.nst);\nif (msg.payload.gap) delete(msg.payload.gap);\nif (msg.payload.dmin) delete(msg.payload.dmin);\nif (msg.payload.magType) delete(msg.payload.magType);\nif (msg.payload.id) delete(msg.payload.id);\nif (msg.payload.updated) delete(msg.payload.updated);\nif (msg.payload.rms) delete(msg.payload.rms);\nif (msg.payload.net) delete(msg.payload.net);\nreturn [ msg ];","outputs":"1","noerr":0,"x":308,"y":265,"z":"29609aca.d69f66","wires":[["66f14749.990eb8"]]},{"id":"86781b39.7987e8","type":"csv","name":"CSV to JSON","sep":",","hdrin":true,"hdrout":"","multi":"one","ret":"\\n","temp":"\"time\", \"latitude\", \"longitude\", \"depth\", \"mag\", \"magType\", \"nst\", \"gap\", \"dmin\", \"rms\", \"net\", \"id\", \"updated\", \"place\", \"type\" ","x":282,"y":165,"z":"29609aca.d69f66","wires":[["3bb724f.fc448dc"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment