无法用arduiono套件中的温度传感器测量温度值

问题描述:

无法测量arduino中温度传感器的温度, 其给出错误的温度=温度= 499.51 * c。即时连接温度传感器到Arduino uno套件。我需要像35的温度值无法用arduiono套件中的温度传感器测量温度值

int val; 
int tempPin = 1; 

void setup() 
{ 
    Serial.begin(9600); 
} 
void loop() 
{ 
    val = analogRead(tempPin); 
    float mv = (val/1024.0) * 5000; 
    float cel = mv/10; 
    float farh = (cel * 9)/5 + 32; 

    Serial.print("TEMPRATURE = "); 
    Serial.print(cel); 
    Serial.print("*C"); 
    Serial.println(); 
    delay(1000); 

    /* uncomment this to get temperature in farenhite 
    Serial.print("TEMPRATURE = "); 
    Serial.print(farh); 
    Serial.print("*F"); 
    Serial.println(); 


    */ 
} 

你不清楚你使用的是什么温度传感器。从你的代码看,你似乎使用模拟传感器。如果是这样,你应该

a) check the data sheet of the sensor and adjust your code accordingly 
OR 
b) calibrate your system by taking readings of known temperatures and adjusting your code accordingly. 

随着你给的信息,它很难更具体。