diff --git a/GPS.py b/GPS.py index 64652fd..d802cfc 100755 --- a/GPS.py +++ b/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: @@ -85,4 +95,4 @@ except: GPIO.cleanup() if ser != None: ser.close() - GPIO.cleanup() + GPIO.cleanup() diff --git a/gps_coordinates.db b/gps_coordinates.db new file mode 100644 index 0000000..c9b5c06 Binary files /dev/null and b/gps_coordinates.db differ