def sendDataToServer():
global temperature
threading.Timer(5.0, sendDataToServer).start()
print("Sensing...")
readSensor()
readCPUTemperature()
temperature = round(temperature, 1)
print(temperature)
print(humidity)
print(pressure)
temp = "%.1f" % temperature
hum = "%.1f" % humidity
press = "%.1f" % pressure
urllib.urlopen("http://www.teema.club/projectweather/add_data.php?temp=" + temp + "&hum=" + hum + "&pr=" + press).read()
sendDataToServer()
This is my Python code which sends some values to a server using a url with some parameters. I need to send this data to server after every 5 seconds. I tried to use a thread but it does not work.
Can anyone tell me is it proper way to do this?