2024-07-26 -

This commit is contained in:
Adolfo Delorenzo 2024-07-26 21:14:41 -06:00
parent a0a30d0b4d
commit ea6447c0d2
3 changed files with 309 additions and 0 deletions

View File

@ -6203,3 +6203,109 @@ Timestamp,Latitude,Longitude
2024-07-26 20:41:38,9.939980,-84.104933
2024-07-26 20:41:53,9.939978,-84.104930
2024-07-26 20:42:08,9.939977,-84.104930
2024-07-26 20:42:23,9.939977,-84.104929
2024-07-26 20:42:38,9.939977,-84.104930
2024-07-26 20:47:43,9.940135,-84.105609
2024-07-26 20:47:58,9.939950,-84.105105
2024-07-26 20:48:13,9.939936,-84.105062
2024-07-26 20:48:28,9.939933,-84.105056
2024-07-26 20:48:43,9.939931,-84.105053
2024-07-26 20:48:59,9.939930,-84.105048
2024-07-26 20:49:14,9.939927,-84.105040
2024-07-26 20:49:29,9.939922,-84.105027
2024-07-26 20:49:44,9.939913,-84.105003
2024-07-26 20:49:59,9.939923,-84.105026
2024-07-26 20:50:14,9.939936,-84.105058
2024-07-26 20:50:29,9.939938,-84.105061
2024-07-26 20:50:44,9.939950,-84.105090
2024-07-26 20:50:59,9.939950,-84.105089
2024-07-26 20:51:14,9.939950,-84.105087
2024-07-26 20:51:29,9.939950,-84.105085
2024-07-26 20:51:44,9.939950,-84.105085
2024-07-26 20:51:59,9.939951,-84.105084
2024-07-26 20:52:14,9.939951,-84.105082
2024-07-26 20:52:29,9.939951,-84.105080
2024-07-26 20:52:44,9.939949,-84.105073
2024-07-26 20:52:59,9.939947,-84.105066
2024-07-26 20:53:14,9.939945,-84.105057
2024-07-26 20:53:29,9.939943,-84.105050
2024-07-26 20:53:44,9.939942,-84.105043
2024-07-26 20:53:59,9.939942,-84.105040
2024-07-26 20:54:14,9.939942,-84.105039
2024-07-26 20:54:29,9.939942,-84.105038
2024-07-26 20:54:44,9.939943,-84.105036
2024-07-26 20:54:59,9.939941,-84.105032
2024-07-26 20:55:14,9.939939,-84.105027
2024-07-26 20:55:29,9.939939,-84.105026
2024-07-26 20:55:44,9.939939,-84.105023
2024-07-26 20:55:59,9.939938,-84.105022
2024-07-26 20:56:14,9.939938,-84.105022
2024-07-26 20:56:29,9.939939,-84.105022
2024-07-26 20:56:44,9.939939,-84.105021
2024-07-26 20:56:59,9.939939,-84.105021
2024-07-26 20:57:14,9.939939,-84.105020
2024-07-26 20:57:29,9.939939,-84.105020
2024-07-26 20:57:44,9.939940,-84.105019
2024-07-26 20:57:59,9.939939,-84.105017
2024-07-26 20:58:14,9.939938,-84.105014
2024-07-26 20:58:29,9.939936,-84.105009
2024-07-26 20:58:44,9.939935,-84.105005
2024-07-26 20:58:59,9.939934,-84.105002
2024-07-26 20:59:14,9.939933,-84.104999
2024-07-26 20:59:29,9.939933,-84.104997
2024-07-26 20:59:44,9.939933,-84.104996
2024-07-26 20:59:59,9.939938,-84.105006
2024-07-26 21:00:14,9.939937,-84.105004
2024-07-26 21:00:29,9.939936,-84.105001
2024-07-26 21:00:45,9.939935,-84.104996
2024-07-26 21:01:00,9.939934,-84.104995
2024-07-26 21:01:15,9.939934,-84.104993
2024-07-26 21:01:30,9.939933,-84.104992
2024-07-26 21:01:45,9.939933,-84.104991
2024-07-26 21:02:00,9.939933,-84.104991
2024-07-26 21:02:15,9.939933,-84.104990
2024-07-26 21:02:30,9.939933,-84.104990
2024-07-26 21:02:45,9.939933,-84.104990
2024-07-26 21:03:00,9.939933,-84.104988
2024-07-26 21:03:15,9.939932,-84.104985
2024-07-26 21:03:30,9.939931,-84.104983
2024-07-26 21:03:45,9.939930,-84.104979
2024-07-26 21:04:00,9.939929,-84.104977
2024-07-26 21:04:15,9.939929,-84.104975
2024-07-26 21:04:30,9.939928,-84.104974
2024-07-26 21:04:45,9.939928,-84.104973
2024-07-26 21:05:00,9.939937,-84.104942
2024-07-26 21:05:15,9.939951,-84.104931
2024-07-26 21:05:30,9.939952,-84.104929
2024-07-26 21:05:45,9.939953,-84.104930
2024-07-26 21:06:00,9.939952,-84.104929
2024-07-26 21:06:15,9.939949,-84.104929
2024-07-26 21:07:15,9.939947,-84.104928
2024-07-26 21:07:30,9.939947,-84.104927
2024-07-26 21:07:45,9.939947,-84.104927
2024-07-26 21:08:00,9.939947,-84.104926
2024-07-26 21:08:15,9.939947,-84.104926
2024-07-26 21:08:30,9.939947,-84.104926
2024-07-26 21:08:45,9.939947,-84.104926
2024-07-26 21:09:00,9.939947,-84.104925
2024-07-26 21:09:15,9.939947,-84.104925
2024-07-26 21:09:30,9.939947,-84.104924
2024-07-26 21:09:45,9.939947,-84.104923
2024-07-26 21:10:00,9.939948,-84.104922
2024-07-26 21:10:15,9.939948,-84.104920
2024-07-26 21:10:30,9.939949,-84.104918
2024-07-26 21:10:45,9.939953,-84.104922
2024-07-26 21:11:00,9.939955,-84.104922
2024-07-26 21:11:15,9.939955,-84.104921
2024-07-26 21:11:30,9.939957,-84.104918
2024-07-26 21:11:45,9.939957,-84.104916
2024-07-26 21:12:01,9.939957,-84.104915
2024-07-26 21:12:16,9.939957,-84.104913
2024-07-26 21:12:31,9.939958,-84.104913
2024-07-26 21:12:46,9.939958,-84.104913
2024-07-26 21:13:01,9.939958,-84.104912
2024-07-26 21:13:16,9.939957,-84.104911
2024-07-26 21:13:46,9.939956,-84.104910
2024-07-26 21:14:01,9.939956,-84.104910
2024-07-26 21:14:16,9.939956,-84.104909
2024-07-26 21:14:31,9.939956,-84.104909

1 Timestamp Latitude Longitude
6203 2024-07-26 20:41:38 9.939980 -84.104933
6204 2024-07-26 20:41:53 9.939978 -84.104930
6205 2024-07-26 20:42:08 9.939977 -84.104930
6206 2024-07-26 20:42:23 9.939977 -84.104929
6207 2024-07-26 20:42:38 9.939977 -84.104930
6208 2024-07-26 20:47:43 9.940135 -84.105609
6209 2024-07-26 20:47:58 9.939950 -84.105105
6210 2024-07-26 20:48:13 9.939936 -84.105062
6211 2024-07-26 20:48:28 9.939933 -84.105056
6212 2024-07-26 20:48:43 9.939931 -84.105053
6213 2024-07-26 20:48:59 9.939930 -84.105048
6214 2024-07-26 20:49:14 9.939927 -84.105040
6215 2024-07-26 20:49:29 9.939922 -84.105027
6216 2024-07-26 20:49:44 9.939913 -84.105003
6217 2024-07-26 20:49:59 9.939923 -84.105026
6218 2024-07-26 20:50:14 9.939936 -84.105058
6219 2024-07-26 20:50:29 9.939938 -84.105061
6220 2024-07-26 20:50:44 9.939950 -84.105090
6221 2024-07-26 20:50:59 9.939950 -84.105089
6222 2024-07-26 20:51:14 9.939950 -84.105087
6223 2024-07-26 20:51:29 9.939950 -84.105085
6224 2024-07-26 20:51:44 9.939950 -84.105085
6225 2024-07-26 20:51:59 9.939951 -84.105084
6226 2024-07-26 20:52:14 9.939951 -84.105082
6227 2024-07-26 20:52:29 9.939951 -84.105080
6228 2024-07-26 20:52:44 9.939949 -84.105073
6229 2024-07-26 20:52:59 9.939947 -84.105066
6230 2024-07-26 20:53:14 9.939945 -84.105057
6231 2024-07-26 20:53:29 9.939943 -84.105050
6232 2024-07-26 20:53:44 9.939942 -84.105043
6233 2024-07-26 20:53:59 9.939942 -84.105040
6234 2024-07-26 20:54:14 9.939942 -84.105039
6235 2024-07-26 20:54:29 9.939942 -84.105038
6236 2024-07-26 20:54:44 9.939943 -84.105036
6237 2024-07-26 20:54:59 9.939941 -84.105032
6238 2024-07-26 20:55:14 9.939939 -84.105027
6239 2024-07-26 20:55:29 9.939939 -84.105026
6240 2024-07-26 20:55:44 9.939939 -84.105023
6241 2024-07-26 20:55:59 9.939938 -84.105022
6242 2024-07-26 20:56:14 9.939938 -84.105022
6243 2024-07-26 20:56:29 9.939939 -84.105022
6244 2024-07-26 20:56:44 9.939939 -84.105021
6245 2024-07-26 20:56:59 9.939939 -84.105021
6246 2024-07-26 20:57:14 9.939939 -84.105020
6247 2024-07-26 20:57:29 9.939939 -84.105020
6248 2024-07-26 20:57:44 9.939940 -84.105019
6249 2024-07-26 20:57:59 9.939939 -84.105017
6250 2024-07-26 20:58:14 9.939938 -84.105014
6251 2024-07-26 20:58:29 9.939936 -84.105009
6252 2024-07-26 20:58:44 9.939935 -84.105005
6253 2024-07-26 20:58:59 9.939934 -84.105002
6254 2024-07-26 20:59:14 9.939933 -84.104999
6255 2024-07-26 20:59:29 9.939933 -84.104997
6256 2024-07-26 20:59:44 9.939933 -84.104996
6257 2024-07-26 20:59:59 9.939938 -84.105006
6258 2024-07-26 21:00:14 9.939937 -84.105004
6259 2024-07-26 21:00:29 9.939936 -84.105001
6260 2024-07-26 21:00:45 9.939935 -84.104996
6261 2024-07-26 21:01:00 9.939934 -84.104995
6262 2024-07-26 21:01:15 9.939934 -84.104993
6263 2024-07-26 21:01:30 9.939933 -84.104992
6264 2024-07-26 21:01:45 9.939933 -84.104991
6265 2024-07-26 21:02:00 9.939933 -84.104991
6266 2024-07-26 21:02:15 9.939933 -84.104990
6267 2024-07-26 21:02:30 9.939933 -84.104990
6268 2024-07-26 21:02:45 9.939933 -84.104990
6269 2024-07-26 21:03:00 9.939933 -84.104988
6270 2024-07-26 21:03:15 9.939932 -84.104985
6271 2024-07-26 21:03:30 9.939931 -84.104983
6272 2024-07-26 21:03:45 9.939930 -84.104979
6273 2024-07-26 21:04:00 9.939929 -84.104977
6274 2024-07-26 21:04:15 9.939929 -84.104975
6275 2024-07-26 21:04:30 9.939928 -84.104974
6276 2024-07-26 21:04:45 9.939928 -84.104973
6277 2024-07-26 21:05:00 9.939937 -84.104942
6278 2024-07-26 21:05:15 9.939951 -84.104931
6279 2024-07-26 21:05:30 9.939952 -84.104929
6280 2024-07-26 21:05:45 9.939953 -84.104930
6281 2024-07-26 21:06:00 9.939952 -84.104929
6282 2024-07-26 21:06:15 9.939949 -84.104929
6283 2024-07-26 21:07:15 9.939947 -84.104928
6284 2024-07-26 21:07:30 9.939947 -84.104927
6285 2024-07-26 21:07:45 9.939947 -84.104927
6286 2024-07-26 21:08:00 9.939947 -84.104926
6287 2024-07-26 21:08:15 9.939947 -84.104926
6288 2024-07-26 21:08:30 9.939947 -84.104926
6289 2024-07-26 21:08:45 9.939947 -84.104926
6290 2024-07-26 21:09:00 9.939947 -84.104925
6291 2024-07-26 21:09:15 9.939947 -84.104925
6292 2024-07-26 21:09:30 9.939947 -84.104924
6293 2024-07-26 21:09:45 9.939947 -84.104923
6294 2024-07-26 21:10:00 9.939948 -84.104922
6295 2024-07-26 21:10:15 9.939948 -84.104920
6296 2024-07-26 21:10:30 9.939949 -84.104918
6297 2024-07-26 21:10:45 9.939953 -84.104922
6298 2024-07-26 21:11:00 9.939955 -84.104922
6299 2024-07-26 21:11:15 9.939955 -84.104921
6300 2024-07-26 21:11:30 9.939957 -84.104918
6301 2024-07-26 21:11:45 9.939957 -84.104916
6302 2024-07-26 21:12:01 9.939957 -84.104915
6303 2024-07-26 21:12:16 9.939957 -84.104913
6304 2024-07-26 21:12:31 9.939958 -84.104913
6305 2024-07-26 21:12:46 9.939958 -84.104913
6306 2024-07-26 21:13:01 9.939958 -84.104912
6307 2024-07-26 21:13:16 9.939957 -84.104911
6308 2024-07-26 21:13:46 9.939956 -84.104910
6309 2024-07-26 21:14:01 9.939956 -84.104910
6310 2024-07-26 21:14:16 9.939956 -84.104909
6311 2024-07-26 21:14:31 9.939956 -84.104909

98
gpsinflux.py Normal file
View File

@ -0,0 +1,98 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import RPi.GPIO as GPIO
import serial
import time
from datetime import datetime
import os
import signal
from influxdb_client import InfluxDBClient, Point
from influxdb_client.client.write_api import SYNCHRONOUS
# GPIO configuration
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
ser = serial.Serial('/dev/ttyUSB3', 115200)
ser.flushInput()
myhost = os.uname()[1]
# InfluxDB settings
INFLUXDB_URL = "http://100.64.0.24:8086"
INFLUXDB_TOKEN = "IPtqPXbaXuuMHvx_tUOt1cmIZfLHucd-9DcepXTVpQc-fNKBhp6pkhyTsq_XnoGXdxwILy5AFFgZ_QUZCE5Jhg=="
INFLUXDB_ORG = "juandiego" # Replace with your organization name
INFLUXDB_BUCKET = "gps_data"
# Initialize InfluxDB client
client = InfluxDBClient(url=INFLUXDB_URL, token=INFLUXDB_TOKEN, org=INFLUXDB_ORG)
write_api = client.write_api(write_options=SYNCHRONOUS)
# Global flag for graceful exit
running = True
def signal_handler(sig, frame):
global running
print('You pressed Ctrl+C! Stopping GPS tracking...')
running = False
signal.signal(signal.SIGINT, signal_handler)
def parse_gps_data(gps_string):
parts = gps_string.split(',')
if len(parts) < 4:
return None
lat = float(parts[0][:2]) + float(parts[0][2:]) / 60
if parts[1] == 'S':
lat = -lat
lon = float(parts[2][:3]) + float(parts[2][3:]) / 60
if parts[3] == 'W':
lon = -lon
return f"{lat:.6f}", f"{lon:.6f}"
def write_to_influxdb(lat, lon):
point = Point("gps_location") \
.tag("host", myhost) \
.field("latitude", float(lat)) \
.field("longitude", float(lon))
write_api.write(bucket=INFLUXDB_BUCKET, record=point)
def send_at(command, back, timeout):
ser.write((command + '\r\n').encode())
time.sleep(timeout)
if ser.inWaiting():
time.sleep(0.01)
rec_buff = ser.read(ser.inWaiting()).decode()
if back in rec_buff:
gps_data = rec_buff.split('+CGPSINFO: ')[1].split('\r\n')[0]
parsed_data = parse_gps_data(gps_data)
if parsed_data:
lat, lon = parsed_data
print(f"GPS: Lat: {lat}, Lon: {lon}")
write_to_influxdb(lat, lon)
return 1
return 0
def get_gps_position():
send_at('AT+CGPSINFO', '+CGPSINFO:', 1)
def initialize_gps():
print('Starting GPS')
send_at('AT+CGPS=1', 'OK', 1)
time.sleep(2)
initialize_gps()
print("Starting continuous GPS tracking. Press Ctrl+C to stop.")
while running:
get_gps_position()
time.sleep(14) # Wait for 14 seconds before the next reading
ser.close()
GPIO.cleanup()
client.close()
print("GPS tracking stopped. Goodbye!")

105
gpsinflux01.py Normal file
View File

@ -0,0 +1,105 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import RPi.GPIO as GPIO
import serial
import time
from datetime import datetime
import os
import signal
from influxdb_client import InfluxDBClient, Point
from influxdb_client.client.write_api import SYNCHRONOUS
# GPIO configuration
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
ser = serial.Serial('/dev/ttyUSB3', 115200)
ser.flushInput()
myhost = os.uname()[1]
# InfluxDB settings
INFLUXDB_URL = "http://100.64.0.24:8086"
INFLUXDB_TOKEN = "IPtqPXbaXuuMHvx_tUOt1cmIZfLHucd-9DcepXTVpQc-fNKBhp6pkhyTsq_XnoGXdxwILy5AFFgZ_QUZCE5Jhg=="
INFLUXDB_ORG = "juandiego" # Replace with your organization name
INFLUXDB_BUCKET = "gps_data"
# Initialize InfluxDB client
client = InfluxDBClient(url=INFLUXDB_URL, token=INFLUXDB_TOKEN, org=INFLUXDB_ORG)
write_api = client.write_api(write_options=SYNCHRONOUS)
# Global flag for graceful exit
running = True
def signal_handler(sig, frame):
global running
print('You pressed Ctrl+C! Stopping GPS tracking...')
running = False
signal.signal(signal.SIGINT, signal_handler)
def parse_gps_data(gps_string):
parts = gps_string.split(',')
if len(parts) < 4:
return None
lat = float(parts[0][:2]) + float(parts[0][2:]) / 60
if parts[1] == 'S':
lat = -lat
lon = float(parts[2][:3]) + float(parts[2][3:]) / 60
if parts[3] == 'W':
lon = -lon
return lat, lon
def write_to_influxdb(lat, lon):
timestamp = int(time.time() * 1000000000) # nanosecond precision
lat_point = Point("latitude") \
.tag("host", myhost) \
.field("_value", lat) \
.time(timestamp)
lon_point = Point("longitude") \
.tag("host", myhost) \
.field("_value", lon) \
.time(timestamp)
write_api.write(bucket=INFLUXDB_BUCKET, record=[lat_point, lon_point])
def send_at(command, back, timeout):
ser.write((command + '\r\n').encode())
time.sleep(timeout)
if ser.inWaiting():
time.sleep(0.01)
rec_buff = ser.read(ser.inWaiting()).decode()
if back in rec_buff:
gps_data = rec_buff.split('+CGPSINFO: ')[1].split('\r\n')[0]
parsed_data = parse_gps_data(gps_data)
if parsed_data:
lat, lon = parsed_data
print(f"GPS: Lat: {lat:.6f}, Lon: {lon:.6f}")
write_to_influxdb(lat, lon)
return 1
return 0
def get_gps_position():
send_at('AT+CGPSINFO', '+CGPSINFO:', 1)
def initialize_gps():
print('Starting GPS')
send_at('AT+CGPS=1', 'OK', 1)
time.sleep(2)
initialize_gps()
print("Starting continuous GPS tracking. Press Ctrl+C to stop.")
while running:
get_gps_position()
time.sleep(14) # Wait for 14 seconds before the next reading
ser.close()
GPIO.cleanup()
client.close()
print("GPS tracking stopped. Goodbye!")