Hi @DrJeff and @glmnet, sorry i was away for a few days. I managed to figure it out, or at least something out. Steinhart-hart is a formula to translate resistance into temperature. It is not exact but accurate, and it relies on these 3 factors called āaā, ābā, and ācā which are unique to the specific thermistor being used. Apparently manufacturers are listing in their specs what a/b/c are for a specific model of thermistor. But not pool equipment manufacturersā¦So the a/b/c that I was able to find in posts and initially used just did not work out for me and the thermistor I used. The reading were just off.
Then I learned that there is a simplified version of the Steinhart-Hart that uses only one unknown variable instead of 3. Might be less accurate but for my needs certainly good enough.
The formula is (credits here)
It relies on 2 (or more) measurements of R and T to determine B. R0 is expected to be 10,000ohm at 25C.
In practice, hereās what I did :
- I bought [this] , comes in 2 for $20 (https://www.amazon.com/gp/product/B07Q8RHK7D/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1) thermistor
- Configured the ESP to calculate the resistance based on the measured voltage (R = 10000 / (1023/V-1)
sensor:
- platform: adc
pin: A0
name: "Pool Temperature"
update_interval: 2s
accuracy_decimals: 0
filters:
- lambda: return 10000 / (1023/x-1)
Drop the thermistor in a cup of warm water along with my favorite BBQ thermometre
and started and logging in Excel the resistance reading every time the temperature dropped one degree as read in the BBQ thermometre. This is what it looks like (āADC TOPā is my entry, for example when the temperature changed from 45 to 44C I entered 7.78.)
|
|
|
|
|
-0.0005923090 |
-1688.3079 |
|
Celcius |
Kelvin |
1/K |
ADC Top |
ADC Mid |
1/B |
B |
F |
45 |
318.15 |
0.003143 |
7.88 |
7.93 |
-0.0006 |
-1550.5611 |
113 |
44 |
317.15 |
0.003153 |
7.78 |
7.83 |
-0.0006 |
-1567.0208 |
111 |
43 |
316.15 |
0.003163 |
7.70 |
7.74 |
-0.0006 |
-1588.3218 |
109 |
42 |
315.15 |
0.003173 |
7.60 |
7.65 |
-0.0006 |
-1611.7869 |
108 |
41 |
314.15 |
0.003183 |
7.49 |
7.55 |
-0.0006 |
-1626.1842 |
106 |
40 |
313.15 |
0.003193 |
7.39 |
7.44 |
-0.0006 |
-1641.8450 |
104 |
39 |
312.15 |
0.003204 |
7.29 |
7.34 |
-0.0006 |
-1663.5457 |
102 |
38 |
311.15 |
0.003214 |
7.18 |
7.24 |
-0.0006 |
-1682.9510 |
100 |
37 |
310.15 |
0.003224 |
7.07 |
7.13 |
-0.0006 |
-1699.2776 |
99 |
36 |
309.15 |
0.003235 |
6.96 |
7.02 |
-0.0006 |
-1717.4057 |
97 |
35 |
308.15 |
0.003245 |
6.88 |
6.92 |
-0.0006 |
-1757.7645 |
95 |
34 |
307.15 |
0.003256 |
6.76 |
6.82 |
-0.0006 |
-1798.6205 |
93 |
33 |
306.15 |
0.003266 |
6.61 |
6.69 |
-0.0006 |
-1788.7405 |
91 |
32 |
305.15 |
0.003277 |
6.48 |
6.55 |
-0.0006 |
-1762.5140 |
90 |
31 |
304.15 |
0.003288 |
6.36 |
6.42 |
-0.0006 |
-1758.0857 |
88 |
30 |
303.15 |
0.003299 |
6.25 |
6.31 |
-0.0006 |
-1776.0250 |
86 |
29 |
302.15 |
0.00331 |
6.10 |
6.18 |
-0.0006 |
-1743.4930 |
84 |
28 |
301.15 |
0.003321 |
5.99 |
6.05 |
-0.0006 |
-1680.1462 |
82 |
27 |
300.15 |
0.003332 |
5.89 |
5.94 |
-0.0006 |
-1727.8155 |
81 |
26 |
299.15 |
0.003343 |
5.78 |
5.84 |
-0.0005 |
-1853.3981 |
79 |
25 |
298.15 |
0.003354 |
5.65 |
5.72 |
|
|
77 |
With about 20 readings (30 minutes or so) i was able to get a bunch of B readings, then I averaged them. For this thermistor it appears B = -0.000592309011930316
Now i can change the code to calculate temperature and it looks like this :
sensor:
- platform: adc
pin: A0
name: "Pool Temperature"
update_interval: 60s
accuracy_decimals: 0
filters:
- lambda: return (1/(0.00335401643468053-0.000592309011930316 * log ((10000/(1023/x-1)) / 5.65) )-273.15) *9/5 + 32;
You can see B in the formula. 0.0033xxx is 1/25C (in Kelvin first). This returns the temp in F.
Bottom line is it works for me. From a science point of view it is probably making a few people cringe, but for measuring the pool temperature it is most definitely good enough ! I have compared the readings from the MCU to those to the BBQ thermometre dunked in the pool and it is within 1 degree F.
Happy to share more if anyone interested !
Disclosure : I am neither an engineer, a coder, a mathematician, or really an expert of any sort But i now know that my pool temperature drops from 72F in the day to 56 at night and I have a nice chart in HA to show me that. Next step is to wire the MCU to the 24v actuator and i do not have to buy this