Wireless WiFi based Thermometers Rated for 0C (lower?) to about 299C.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

106 lines
2.3 KiB

#!/usr/bin/python3
import numpy as np
import matplotlib.pyplot as plt
from scipy.linalg import lstsq
from scipy.stats import linregress
d = []
d.append((int("0000", 16), 0))
d.append((int("000a", 16), 1))
d.append((int("0014", 16), 2))
d.append((int("0032", 16), 5))
d.append((int("0046", 16), 7))
d.append((int("0050", 16), 8))
d.append((int("0064", 16), 10))
d.append((int("012c", 16), 30))
d.append((int("0136", 16), 31))
d.append((int("0140", 16), 32))
d.append((int("014a", 16), 33))
d.append((int("0154", 16), 34))
d.append((int("01f4", 16), 50))
d.append((int("01fe", 16), 51))
d.append((int("0208", 16), 52))
d.append((int("0212", 16), 53))
d.append((int("021c", 16), 54))
d.append((int("0226", 16), 55))
d.append((int("0230", 16), 56))
d.append((int("023a", 16), 57))
d.append((int("0244", 16), 58))
d.append((int("024e", 16), 59))
"""
d.append((int("0000b2", 16), 0))
d.append((int("000abc", 16), 1))
d.append((int("0014c6", 16), 2))
d.append((int("0032e4", 16), 5))
d.append((int("0046f8", 16), 7))
d.append((int("005002", 16), 8))
d.append((int("006416", 16), 10))
d.append((int("012cdf", 16), 30))
d.append((int("0136e9", 16), 31))
d.append((int("0140f3", 16), 32))
d.append((int("014afd", 16), 33))
d.append((int("015407", 16), 34))
d.append((int("01f4a7", 16), 50))
d.append((int("01feb1", 16), 51))
d.append((int("0208bc", 16), 52))
d.append((int("0212c6", 16), 53))
d.append((int("021cd0", 16), 54))
d.append((int("0226da", 16), 55))
d.append((int("0230e4", 16), 56))
d.append((int("023aee", 16), 57))
d.append((int("0244f8", 16), 58))
d.append((int("024e02", 16), 59))
"""
# f4 01 a7: 50
# fe 01 b1: 51
# 08 02 bc: 52
# 12 02 c6: 53
# 1c 02 d0: 54
# 26 02 da: 55
# 30 02 e4: 56
# 3a 02 ee: 57
# 44 02 f8: 58
# 4e 02 02: 59
# e4 02 98: 74
# 02 03 b7: 77
# 4c 04 02: 110
# 56 04 0c: 111
# 60 04 16: 112
# 6a 04 20: 113
# 74 04 2a: 114
# 7e 04 34: 115
# ba 04 70: 121
# ae 06 66: 171
x = np.array([x[0] for x in d])
y = np.array([x[1] for x in d])
M = x[:, np.newaxis]**[0, 2]
slope, intercept, r_value, p_value, std_err = linregress(x,y)
print(linregress(x,y))
plt.plot(x, y, 'o', label='data')
xx = np.linspace(0, 9, 101)
yy = intercept + slope*xx
plt.plot(xx, yy, label='y = mx + b')
plt.xlabel('x')
plt.ylabel('y')
plt.legend(framealpha=1, shadow=True)
plt.grid(alpha=0.25)
plt.show()