NTC Thermistor Temperature Sensor 10Kohm MF52-103 Code

In my Win2016 Server project I decided to add a case temperature sensor to do 3 things.

1) Monitor case temperature
2) Control a case fan
3) Adjust the RGB lighting

I have several MF52-103 thermistors and also several DS18B20 waterproof digital sensors in my drawer, so I went with the simple MF52-103 thermistors. They are easier and smaller to use plus more responsive.

The MF52-103 are NTCs (Negative Temperature Coefficient) which means the resistance decreases when the temperature rises whereas PTCs (Positive Temperature Coefficient) the resistance increases when the temperature rises.

Arduino NTC Thermistor Layout

.Here is some Arduino code for a NTC Thermistor.


// NTC Thermistor Temperature Sensor 10Kohm MF52-103
// Thermistor Wiring:
//   5Vcc -> [10KOhm Resistor] -> Thermistor -> Gnd
//                                |
//                                \-> A0

int ThermistorPin = 0; // A0   
float ThermistorResistance = 10000.0;
float TcV = 0.0; // Temperature celsius Value

float ConvertAnalogReadingToTemperature(int AnalogReadValue, float ThermistorResistanceValue) {
  // If AnalogReadValue is maxed at 1023 it will cause a divide-by-zero so default to 1022
  if(AnalogReadValue == 1023) {
    return 1022.0;
  } 
  return (1/((log(((ThermistorResistanceValue * AnalogReadValue) / (1023.0 - AnalogReadValue))/ThermistorResistanceValue)/3435.0) + (1 / (273.15 + 25.000)))) - 273.15;
}

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

void loop() { 
  TcV = ConvertAnalogReadingToTemperature(analogRead(ThermistorPin),ThermistorResistance);
  Serial.print("TcV ");
  Serial.println(TcV);
}



Comments are closed.