Arduino - 热敏电阻MF58-104F3950K

热敏电阻接法:

这里写图片描述

阻值:

这里写图片描述

/* 
 * 热敏电阻的型号是 NTC玻封热敏电阻MF58-104F 3950K 直插100K 精度1% B值3950
 * 常温25摄氏度(298.15K)下阻值为100k欧 
*/  
#include<math.h>  

const float voltagePower=5;  
const float Rs=100;//采样电阻为100千欧  
const int B=3950;  
const double T1=273.15+25;//常温  
const double R1=100;//常温对应的阻值,注意单位是千欧  


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

void loop() {  

  //获得A0处的电压值  
  double digitalValue=analogRead(0);  
  double voltageValue=(digitalValue/1023)*5;  
  Serial.print("Current voltage value=");  
  Serial.println(voltageValue);  

  //通过分压比获得热敏电阻的阻值  
  double Rt=((voltagePower-voltageValue)*Rs)/voltageValue;  
  Serial.print("Current registor value=");  
  Serial.println(Rt);  

  //换算得到温度值  
  Serial.print("Current temperature value=");  
  Serial.println(((T1*B)/(B+T1*log(Rt/R1)))-273.15);//  
  Serial.println();  

  delay(1000);  

}  

猜你喜欢

转载自blog.csdn.net/sdlgq/article/details/68065716