Skip to content

Instantly share code, notes, and snippets.

@mjdargen
Last active April 15, 2021 12:12
Show Gist options
  • Save mjdargen/a6d535df30f651069401dcc3c9c09df5 to your computer and use it in GitHub Desktop.
Save mjdargen/a6d535df30f651069401dcc3c9c09df5 to your computer and use it in GitHub Desktop.
Steinhardt-Hart Equation for computing temperature from a thermistor.
float R1 = 10000; // resistance value of the fixed resistor
float RT; // resistance value of thermistor
float T; // final temperature value
int therm_val; // where you will store the value from analogRead()
// get the value
/* INSERT CODE HERE TO RETRIEVE THE ANALOG VALUE & STORE IT IN therm_val */
// this is the math equation for computing the resistance of thermistor
RT = R1 * (1023 - therm_val) / therm_val;
// compute temperature in Celsius
// RT is the resistance across the thermistor
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
T = (1 / (c1 + c2*log(RT) + c3*log(RT)*log(RT)*log(RT))) - 273.15;
// now convert the temperature from Fahrenheit to Celsius
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment