diff --git a/earthquake/earthquake.py b/earthquake/earthquake.py new file mode 100644 index 0000000000000000000000000000000000000000..4028cc3065713f49827ae8275c2fd4c726ee8614 --- /dev/null +++ b/earthquake/earthquake.py @@ -0,0 +1,27 @@ +#!/bin/python3 + +import serial +import requests +import time + +if len(sys.argv) < 2: + exit("Usage: earthquake.py [device]") + +ser = serial.Serial(sys.argv[1], 115600) +last = -1000000 + +while True: + line = ser.readline() + if line.startswith("gempa"): + strength = float(line.split(' ')[1]) + if time.time() - last >= 36000: + + data = { + "lat": -6.892004, + "long": 107.599828, + "strength": strength, + "date": "2017-12-06 PM 22:03:36.000Z" + } + + request.post('jauhararifin.cf:8888/api/earchquake', data) + last = time.time() \ No newline at end of file