找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 534|回复: 0
打印 上一主题 下一主题
收起左侧

NTC 10K 热敏传感器程序

[复制链接]
跳转到指定楼层
楼主
ID:396487 发表于 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 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表