2024-07-11 -
This commit is contained in:
parent
9d8b7356a1
commit
8a13ea9ab6
10
GPS.py
10
GPS.py
@ -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:
|
||||
|
BIN
gps_coordinates.db
Normal file
BIN
gps_coordinates.db
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user