-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.py
More file actions
50 lines (35 loc) · 716 Bytes
/
temp.py
File metadata and controls
50 lines (35 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import serial
from time import sleep, time
import sys
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
from shutter import Shutter
plotting = False
def main():
shut = Shutter()
t0 = time()
t = []
temp = []
file = open("temp_out.txt", "w")
if plotting:
plt.ion()
while(True):
val = shut.getTemperature()
print(val)
now = time()
t.append(now-t0)
temp.append(val)
data = str(time()) + ',' + str(t[-1]) + ',' + str(temp[-1]) + '\n'
file.write(data)
file.flush()
if plotting:
plt.plot(t, temp, 'r+', markersize=1)
plt.show()
plt.pause(0.005)
sleep(1)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
raise SystemExit