#!/usr/bin/python
import socket, requests
from subprocess import call
UDP_PORT = 12345
UDP_IP = ""
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((UDP_IP,UDP_PORT))
print "Listening on UDP port: "+str(UDP_PORT)
while True:
data, addr = sock.recvfrom(1024)
print addr[0],data
if data.find("->"):
influxValueFind = data.find("->")+3
influxValue = data[influxValueFind:influxValueFind+5]
influxLoc = data[data.find("(")+1:data.find(")")]
r=requests.post('http://10.0.1.202:8086/write?db=mydb', 'temperature,host=ESP00000,location=%s value=%s'%(influxLoc,influxValue))
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.