// Three point calibration Steinhart-Hart coefficient fitting
//Measured Data:
// data 0 T:-24.00 R:135248.20
// data 1 T:25.00 R:10019.55
// data 2 T:80.00 R:1271.33
// Fitted Coefficients
// float c1 = 1.0266267e-03; //coefficient A
// float c2 = 2.5236164e-04; //coefficient B
// float c3 = 3.2744565e-09; //coefficient C
// From https://forum.arduino.cc/t/problema-usando-termistores-pasate-aca/513763
// and https://www.circuitbasics.com/arduino-thermistor-temperature-sensor-tutorial/
// With modified values
//This is an example code on how to read a thermistor, the "Thermimistor.h" Lib out there only acepts Beta
//coeficient and in my case yield to incorrects results, this a way more accuerrate way to read the
//thermistor, in case you have odd or wrong meassurements please follow this steps:
//
//For get the acurrate results for this code you will need;
//a multymeter, a NTC thermistor, another accurrate themperature
//probe meter.
//Step 1.- Set multimiter on resistance meassurement mode
//Step 2.- Read and anotate the actual resistance of the thermistor
//and the actual temperature (allow 1min to get stable meassurement).
//Some Hot water and a cup.
//Step 3.- place both sensors (Thermistor and temperature probe in a
//recipient containing water at ambient temperature).
//In another cup heat up some water.
//Add hot water until you heat more than 10°C the temp probe, wait for
//stable meassurement and anotate the temperature and the resistance.
//Add more water to heat up the element 20° from the first meassurement.
//Take note of the temperature and resistance.
//Step 4.-
//Go to the website:
//http://www.thinksrs.com/downloads/programs/Therm%20Calc/NTCCalibrator/NTCcalculator.htm
//and set your data on it.
//The calculator will deliver three values we need on the code: A, B and C.
//Step 5.-
//Replace the values you get in the calculator on this code.
//Step 6.- Upload and test it.
//Place both sensors on ambien water, warm water and hot water, use the temperature
//probe to chek for accurracy.
//Original code from: https://www.youtube.com/watch?v=-_XkGju35MI
//Procedure: Alex Santiago - 12/03/2018
//Tested on a 10K NTC B3450 -12/03/2018
//Arduino Mega at 5Vcc.
int ThermistorPin = A1;
float Vo;
float R1 = 10000;
float logR2, R2, T, Tc, Tf;
float c1 = 1.0266267e-03; //coefficient A
float c2 = 2.5236164e-04; //coefficient B
float c3 = 3.2744565e-09; //coefficient C
void setup() {
Serial.begin(9600);
}
void loop() {
Vo = analogRead(ThermistorPin)+0.5;
// There are two ways to wire a thermistor as R2:
R2 = R1 / (1024.0 / (float)Vo - 1.0); // VCC-R1-R_therm-GND (pullup+NTC)
//R2 = R1 * ( 1024.0/Vo -1 ); // VCC-R_therm-R1-GND (NTC+pulldown)
logR2 = log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
Tc = T - 273.15;
Tf = (Tc * 9.0)/ 5.0 + 32.0;
Serial.print("Resistance: ");
Serial.print(R2);
Serial.print(" Temperature: ");
Serial.print(Tc);
Serial.println(" C");
delay(500);
}
//