首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法使用arduiono套件中的温度传感器测量温度值

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

Stack Overflow用户
提问于 2016-03-28 20:02:44
回答 1查看 98关注 0票数 1

无法从arduino的温度传感器测量温度,它给出了错误的temp = Temprature =499.51 * c。我将温度传感器连接到arduino uno套件。我需要像35这样的临时值

代码语言:javascript
运行
复制
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();


  */
}
EN

回答 1

Stack Overflow用户

发布于 2016-03-28 20:46:58

目前尚不清楚您使用的是哪种温度传感器。从您的代码看,您似乎使用了模拟传感器。如果是这样,您应该

代码语言:javascript
运行
复制
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.

根据你给出的信息,很难说得更具体。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36261913

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档