# Python program to record temperature to data file every 1 s # date 2017-09-03 # Copyright 2017 Greg Altimas #import RPi.GPIO as GPIO import time for i in range (10000000): datafile = open("temperatureOneYear.txt", "a") tfile = open("/sys/bus/w1/devices/w1_bus_master1/22-0000003b4021/w1_slave") text = tfile.read() tfile.close() secondline = text.split("\n")[1] tempdata = secondline.split(" ")[9] temperature = float(tempdata[2:]) temperature = temperature / 1000 timestamp = time.ctime() datafile.write(timestamp + "\t" + str(temperature) + "\n") datafile.close() time.sleep(30)