//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 accurrate 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 ambient 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;
int Vo;
float R1 = 10000;
float logR2, R2, T, Tc, Tf;
float c1 = 1.290256288e-03; //coeficient A
float c2 = 1.901591170e-04; //coeficient B 
float c3 = 3.997482735e-07; //coeficient C 

void setup() {
Serial.begin(9600);
}

void loop() {

  Vo = analogRead(ThermistorPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  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("Temperature:   "); 
  Serial.print(Tc);
  Serial.println(" C");   

  delay(500);
}
//
//
//
//
//

//