# Templogging Script import os import time # Settings M_TIME = 5 # Measure time interval counter = 0 def getCPUtemp(): res = os.popen('vcgencmd measure_temp').readline() return (res.replace("temp=", "").replace("'C\n", "")) print "starting logging ..." print "press ctrl + c to exit" # this rewrite the file! f = open('temp_log.txt', 'w') # write file header line f.write('Temp LOG - time interval = {0} s\n'.format(M_TIME)) while True: temp_float = float(getCPUtemp()) try: #print temp_float # write lines with timestamps in csv format f.write('{0},{1}\n'.format(counter,temp_float)) counter = counter + M_TIME except: print "FEHLER" time.sleep(M_TIME) f.close()