From 7923e98a2215f0a7d7fbf9913a5541b884717fe4 Mon Sep 17 00:00:00 2001 From: Adolfo Delorenzo Date: Thu, 11 Jul 2024 19:04:50 -0600 Subject: [PATCH] 2024-07-11 - --- GPS.py | 27 +++----------- coordinates.txt | 95 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 92 insertions(+), 30 deletions(-) diff --git a/GPS.py b/GPS.py index 64b0f4b..64652fd 100755 --- a/GPS.py +++ b/GPS.py @@ -1,21 +1,12 @@ #!/usr/bin/python # -*- coding:utf-8 -*- import RPi.GPIO as GPIO -import paho.mqtt.client as mqtt import serial import time, os -# MQTT Broker settings - -mqttBroker ="65.108.199.212" -myhost = os.uname()[1] -client = mqtt.Client(myhost) -client.connect(mqttBroker, 1883) - ser = serial.Serial('/dev/ttyS0',115200) ser.flushInput() - rec_buff = '' rec_buff2 = '' time_count = 0 @@ -48,17 +39,12 @@ def get_gps_position(): time.sleep(2) while rec_null: answer = send_at('AT+CGPSINFO','+CGPSINFO: ',1) - client.publish("iiot/"+ myhost +"/gps", answer, 0) if 1 == answer: answer = 0 if ',,,,,,' in rec_buff: - gps_info = extract_gps_info(rec_buff) - client.publish("iiot/" + myhost + "/gps", gps_info, 2) - return True - else: - print('GPS no está listo') - rec_null = False - time.sleep(1) + print('GPS no está listo') + rec_null = False + time.sleep(1) else: print('error %d'%answer) rec_buff = '' @@ -66,11 +52,6 @@ def get_gps_position(): return False time.sleep(1.5) -def extract_gps_info(rec_buff): - # Implement this function based on the format of rec_buff - # Example: gps_info = rec_buff.split(',')[2] - return gps_info - def power_on(power_key): print('SIM7600X is starting:') @@ -104,4 +85,4 @@ except: GPIO.cleanup() if ser != None: ser.close() - GPIO.cleanup() + GPIO.cleanup() diff --git a/coordinates.txt b/coordinates.txt index 4ac062f..e378075 100644 --- a/coordinates.txt +++ b/coordinates.txt @@ -1,25 +1,106 @@ Iniciando GPS -AT+CGPS=1,1 ERROR -AT+CGPS=1,1 back: AT+CGPS=1,1 -ERROR +AT+CGPS=0 +OK + ++CGPS: 0 AT+CGPSINFO -+CGPSINFO: 0956.397161,N,08406.296290,W,110724,205340.0,1153.2,0.0, ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, OK AT+CGPSINFO -+CGPSINFO: 0956.397161,N,08406.296288,W,110724,205342.0,1153.2,0.0, ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, OK AT+CGPSINFO -+CGPSINFO: 0956.397165,N,08406.296286,W,110724,205345.0,1153.2,0.0, ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, OK AT+CGPSINFO -+CGPSINFO: 0956.397165,N,08406.296287,W,110724,205347.0,1153.2,0.0, ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, + +OK + +AT+CGPSINFO ++CGPSINFO: 0956.398923,N,08406.296438,W,120724,010243.0,1137.5,0.0, OK