Mirror 2 - with clock, weather information and sensors for room temperature or something else, where you can see information
Since I am interested in microprocessors, I decided to try to connect the sensor. This is how the idea of connecting a "Magic Mirror" to a temperature sensor. Temperature sensor DHT11. Unfortunately he only works with Raspberry Pi 3 or Arduino. Requires special Python_DHT library. Otherwise, nothing will go wrong.
#!/usr/bin/env python
import Python_DHT
window = Tk()
window.configure(background = 'green')
window.bind('<Escape>', lambda e: window.destroy())
window.geometry (150x150)
O_SD =''
def dht_data():
pin = 4
global O_SD
sensor = Python_DHT.DHT11
hmd, tmp = Python_DHT.read_retry(sensor, pin)
SD=(" In room- "+"Temperature: "+str(tmp)+" C"+", "+"Humidity : "+str(hmd)+" %")
if SD != O_SD:
O_SD = SD
sd_label.config (text = SD)
frame_room.after(10000,dht_data)# change GUI labels data every 10 seconds
window.mainloop()
#!/usr/bin/env python
import Python_DHT
window = Tk()
window.configure(background = 'green')
window.bind('<Escape>', lambda e: window.destroy())
window.geometry (150x150)
O_SD =''
def dht_data():
pin = 4
global O_SD
sensor = Python_DHT.DHT11
hmd, tmp = Python_DHT.read_retry(sensor, pin)
SD=(" In room- "+"Temperature: "+str(tmp)+" C"+", "+"Humidity : "+str(hmd)+" %")
if SD != O_SD:
O_SD = SD
sd_label.config (text = SD)
frame_room.after(10000,dht_data)# change GUI labels data every 10 seconds
window.mainloop()