找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 565|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

NTC 10K 熱敏傳感器程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:396487 發(fā)表于 2024-12-16 20:37 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
// 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);
}

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表