Bugfixes to temperature

git-svn-id: http://moon:8086/svn/projects/HendiControl@191 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
2019-03-31 06:39:59 +00:00
parent 25ba72acff
commit 0b669ba655
2 changed files with 8 additions and 4 deletions
+3 -2
View File
@@ -11,6 +11,7 @@ class Max31865():
self.spi.max_speed_hz = 100000 self.spi.max_speed_hz = 100000
self.spi.mode = 0b01 self.spi.mode = 0b01
self.write_reg(0x00, 0xA3) self.write_reg(0x00, 0xA3)
self.temp_correction = -0.2
def read_reg(self, addr): def read_reg(self, addr):
reg = self.spi.xfer([addr, 0xFF]) reg = self.spi.xfer([addr, 0xFF])
@@ -29,8 +30,8 @@ class Max31865():
def getTemperature(self): def getTemperature(self):
digits = self.read_digits() digits = self.read_digits()
R = max31865.calc_R(430, digits) R = Max31865.calc_R(430, digits)
T = max31865.vanDusen_temp(R) T = Max31865.vanDusen_temp(R) + self.temp_correction
print("R={:.3f} Ohm, T={:.2f} degC".format(R, T)) print("R={:.3f} Ohm, T={:.2f} degC".format(R, T))
return T return T
+5 -2
View File
@@ -1,3 +1,4 @@
import time
import numpy as np import numpy as np
from max31865 import Max31865 from max31865 import Max31865
from matplotlib.pyplot import figure, clf, plot, xlabel, ylabel, xlim, ylim, title, grid, axes, show, subplot from matplotlib.pyplot import figure, clf, plot, xlabel, ylabel, xlim, ylim, title, grid, axes, show, subplot
@@ -11,9 +12,10 @@ class TempLogger():
def run(self, dt, duration): def run(self, dt, duration):
for t in range(0, duration): for t in range(0, duration):
temp = self.tempSensor.sensor() temp = self.sensor.getTemperature()
print ("Current temperature is {:0.2f} °C", format(temp)) print ("Current temperature is {:0.2f} °C".format(temp))
self.temps = np.append(self.temps, temp) self.temps = np.append(self.temps, temp)
time.sleep(dt)
if __name__ == '__main__': if __name__ == '__main__':
@@ -21,3 +23,4 @@ if __name__ == '__main__':
logger.run(1, 10) logger.run(1, 10)
print("End of program") print("End of program")