Newbie to Python, started off messing with a DHT11 Temp/Humidity Sensor, a Raspberry Pi 3, and Python 3.
I am using the standard Adafruit DHT11 Library for Python.
Reading from GPIO 27
I am able to display the temperature in a GUI window just fine. What I am stuck on is how to have the GUI update/refresh the temperature at a set rate so it is a "live" display of the current temperature. Right now, I can only get changes from the GUI if I close and reopen my script. See my code below:
from tkinter import *
import tkinter.font
import Adafruit_DHT
temp = 0
win = Tk()
win.title("Temperature")
win.geometry("100x100")
def READ():
global temp
humidity, temperature = Adafruit_DHT.read_retry(11, 27)
temp = temperature * 9/5.0 + 32
Label (win, text=str(temp), fg="black", bg="white", font="36").grid(row=0, column=0)
if (temp >= 0):
READ()
mainloop()