2024-07-11 -

This commit is contained in:
Adolfo Delorenzo 2024-07-11 19:34:49 -06:00
parent 9d8b7356a1
commit 8a13ea9ab6
2 changed files with 11 additions and 1 deletions

12
GPS.py
View File

@ -1,12 +1,21 @@
#!/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
@ -39,6 +48,7 @@ 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:
@ -85,4 +95,4 @@ except:
GPIO.cleanup()
if ser != None:
ser.close()
GPIO.cleanup()
GPIO.cleanup()

BIN
gps_coordinates.db Normal file

Binary file not shown.