无法从arduino的温度传感器测量温度,它给出了错误的temp = Temprature =499.51 * c。我将温度传感器连接到arduino uno套件。我需要像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();
*/
}发布于 2016-03-28 20:46:58
目前尚不清楚您使用的是哪种温度传感器。从您的代码看,您似乎使用了模拟传感器。如果是这样,您应该
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.根据你给出的信息,很难说得更具体。
https://stackoverflow.com/questions/36261913
复制相似问题