Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import matplotlib
- matplotlib.use('Agg')
- import matplotlib.pyplot as plt
- names = ("Fenster","Heizung","Gluehbirne","Schreibtisch","RasPi-Prozessor")
- mask = (1,1,1,1,1)
- file = []
- for i in range(5):
- file.insert(i,open("/home/pi/logs/"+names[i]+".csv", 'w'))
- file[i].seek(0,2)
- keys = ("28-0415a30daeff", "28-0415a30e46ff", "28-0415a35d77ff", "28-0415a35bd5ff", "28-0415a30f6eff")
- times = [[],[],[],[],[]]
- data = [[],[],[],[],[]]
- start = time.time()
- while 1:
- for i in range(5):
- if not mask[i]:
- continue
- ausgabe = open("/sys/bus/w1/devices/"+keys[i]+"/w1_slave").readlines()
- ausgabe[0] = ausgabe[0].split(' ')[11]
- ausgabe[1] = ausgabe[1].split("t=")[1]
- ausgabe[1] = ausgabe[1].rstrip()
- if int(ausgabe[1]) == 85000:
- continue
- if ausgabe[0] == "YES\n":
- file[i].write(str(time.time())+"; "+ausgabe[1]+";\n")
- file[i].flush()
- times[i].append(time.time()-start)
- data[i].append(int(ausgabe[1]))
- print names[i]
- print data[i]
- plt.plot(times[i],data[i])
- plt.xlabel('Zeit ab Start [s]')
- plt.ylabel('Temperatur [mC]')
- plt.title(names[i])
- plt.grid(True)
- plt.savefig("/home/pi/logs/"+names[i]+".png", format="png")
- plt.savefig("/home/pi/logs/"+names[i]+".pdf", format="pdf")
- plt.cla()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement