IT/Arduino
아두이노 교육3일차 서미스터를 이용한 디지털온도계
underbell
2014. 8. 23. 11:20
#include<math.h> #define A 0.001129148 #define B 0.000234125 #define C 0.0000000876741 #define Vin 5.0 #define R2 10000.0 void setup() { Serial.begin(9600); } double SteinharFart(double R) { //NTC 온도 변환 공식 double logR = log(R); double logR3 = pow(logR, 3); return 1.0 / (A + B * logR + C * logR3); } void loop() { int adcData = analogRead(0); double Vout = (adcData * Vin) / 1023; double Rth = ((Vin * R2) / Vout) - R2; double T = SteinharFart(Rth) - 273.15; Serial.println(T); }