无法测量arduino温度传感器的温度, 它给出了错误的温度=温度= 499.51 * c。 im连接温度传感器到arduino uno kit。我需要像35
这样的临时值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();
*/
}
答案 0 :(得分:0)
目前尚不清楚您使用的温度传感器。从您的代码中,您似乎使用模拟传感器。如果是这样,你应该
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.
根据您提供的信息,很难更具体。