標(biāo)題: NTC 10K 熱敏傳感器程序 [打印本頁]

作者: mykt2012    時間: 2024-12-16 20:37
標(biāo)題: NTC 10K 熱敏傳感器程序
// Thermistor parameters from the datasheet
#define RT0 10000
#define B 3977

// Our series resistor value = 10 kΩ
#define R 10000  

// Variables for calculations
float RT, VR, ln, TX, T0, VRT;

void setup() {
  // Setup serial communication
  Serial.begin(9600);
  // Convert T0 from Celsius to Kelvin
  T0 = 25 + 273.15;
}

void loop() {
  // Read the voltage across the thermistor
  VRT = (5.00 / 1023.00) * analogRead(A0);

  // Calculate the voltage across the resistor
  VR = 5.00 - VRT;

  // Calculate resistance of the thermistor
  RT = VRT / (VR / R);

  // Calculate temperature from thermistor resistance
  ln = log(RT / RT0);
  TX = (1 / ((ln / B) + (1 / T0)));

  // Convert to Celsius
  TX = TX - 273.15;

  Serial.print("Temperature: ");
  // Display in Celsius
  Serial.print(TX);                  
  Serial.print("Ct");

  // Convert and display in Kelvin
  Serial.print(TX + 273.15);
  Serial.print("Kt");

  // Convert and display in Fahrenheit
  Serial.print((TX * 1.8) + 32);
  Serial.println("F");

  delay(500);
}


作者: GlenXu    時間: 2025-5-12 08:42
抄收了,很好用!
感謝分享!




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1