Skip to content
Snippets Groups Projects
Commit e78867dc authored by Dery Rahman Ahaddienata 's avatar Dery Rahman Ahaddienata
Browse files
parents d33248a3 c70e1b61
Branches
No related merge requests found
#!/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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment