In the last blog post, I described a long winded approach about how I built a model for a thermister to relate the voltage measured from a BeagleBoneBlack (BBB) microcontroller to the temperature. This post will summarize the results from the model, and explain how to connect up the system.
100K Glass-sealed Thermistor
3950 1% thermistor 1.8mm glass head
1M long cables 2 wires
PTFE Tube 0.6*1mm to protect from the thermistor
Shrink wrap between thermistor and the cables.
The site included a weird word document with a bunch of numbers. I saved the data as a .csv file so I can use the data in python. If you want to follow along, you can you download the document here
I then made a chart which includes the expected resistance and the errors. This chart summarizes the data provided by the manufacturer:
We than then limit the data to operating temperature range which I care about:
Based on the Resistance vs Temperature Chart, we can make an assumption that the distribution follows the relationship followed by this fitness function:
where resistance is meaured in , temperature measued in degrees celcius, and the constants a, b, and c can be found (through curve fitting).
Lets define the fitness function and find the constants a, b, and c.
Now lets plot the expected resistance, curve fit resistance and residuals to understand the error in the curve fit:
Residual mean (Kohm):
Residual std dev (Kohm):
As we can see, the residual error is very small compared to the range of resistance, and follows a (some what) normal distribution. That we have a model of resistance vs temperature, lets set up our microcontroller (BBB) to measure temperature. Since our sensor is a variable resistor, we can take an analog mesaurement by passing a current though the thermister and measuring the voltage accross it. Since we need to limit our input voltage to 1.8 V (according to the BBB spec, we can use a voltage divider to limit the maximum voltage accross the thermistor (as shown below)
In our case, we need to calculate the correct R1 to ensure the voltage accross the thermistor (which is read through the analog input pin of the BBB) does not exceed 1.8V based on the maximum operating range of temperature. For us this is between 0C and 100 C. Based on the plot of the resistance vs temperature for the thermistor, we know that at 0C, the resistance of the thermistor is a maximum of 327.240 Kohm. We can then use this value as R2 in a generic voltage divider, to calculate for R1.
Now that we have R1 and Vin set as constants and we can measure Vo from the BBB’s analog input pin, we can now write a rearrange the voltage divider equation and fitness function to relate Vo to temperature. The previous blog post goes over this, but the resulting function is here:
We can now use this function and plot for the full range of input voltages: