

// we do use a 10 kOhm NTC resistor
// Must be declared BEFORE including ntc.h

/*
  SIMPLE NTC CODE FOR 10 kohm NTC
  ARDUINO STUFF :-)
  (C) JDN free beer license
  setup
    5V ----|10 kohm|-----|10 kohm NTC|----GND
               ^       ^      ^
               R       |    Rntc
                       |
                      analogRead(A0)

  NB 10 bit AD converter so reading from ADC
  is scaled from range 0-1023 to 0-5V

  SO YOU HAVE TO CACULATE Rntc from teh voltage divider above. based on the * voltage and supply voltage

  float voltage = analogRead(A0) ; // or whatever port
  voltage *= 5.0/1023.0; // just going from bits to Volt

  So   Vntc = 5.0*Rntc/(Rntc+R) in this case
  =>
     Vntc*(Rntc+R) = 5.0* Rntc
  =>   Rntc = Vntc*R /(5.0-Vntc)

*/

#define NTC_R_10000
#include <ntc.h>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}


float temp;
void loop() {
  // put your main code here, to run repeatedly:
  // lets us check with some known tempeatures
  Serial.print(" ntc2temp ");
  temp = ntcToTemp(10000.0 ); // should give 25 C
  Serial.print("  "); Serial.print(temp - 273.15); // res is in Kelvin
  temp = tempToNtc(25.0+273.15); // should give 10k/47K or whatsoever
  Serial.print(" "); Serial.println(temp); // res is in Kelvin

  
  Serial.print(" ntc2temp ");
  temp = ntcToTemp(239900.0); // should give -35 C
  Serial.print("  "); Serial.print(temp - 273.15); // res is in Kelvin
 
  temp = tempToNtc(-35.0+273.15); // should give 10k/47K or whatsoever
 Serial.print(" ");  Serial.println(temp); // res is in Kelvin

  Serial.print(" ntc2temp ");Serial.print(" "); 
  temp = ntcToTemp(3605.0); // should give 50 C
  Serial.print(temp - 273.15); // res is in Kelvin
Serial.print(" "); 
  temp = tempToNtc(50.0+273.15 ); // should give 10k/47K or whatsoever
  Serial.println(temp); // res is in Kelvin

  delay(4000);
}

// Jens
