readfridge.py (404B)
1 import serial 2 import os 3 import time 4 5 arduino = serial.Serial(port='/dev/ttyACM0', baudrate=115200, timeout=.1) 6 7 temp = 0 8 oldtemp = 1 9 10 def read(): 11 temp = arduino.readline().decode('utf-8').rstrip() 12 return temp 13 14 while True: 15 temp = read() 16 if oldtemp != temp and temp != '': 17 os.system('python3 client.py' + ' "Kylskåpe: ' + str(temp) + '"') 18 oldtemp = temp 19 time.sleep(10)