这也是37款传感器套件中的一款,传感器的样式如下图所示:

模拟温度传感器的电源引脚在两侧,中间的引脚输出温度相关的模拟量,所以中间的引脚需要接在Arduino的模拟引脚之上。下图是实物连线图:

测试代码如下:用的就是商家资料中提供的代码:
#include<math.h>
double Thermister(int rawADC)
{
double tmp;
tmp = log(((10240000 / rawADC) - 10000));
tmp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * tmp * tmp)) * tmp);
tmp = tmp - 273.15;
return tmp;
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop()
{
// put your main code here, to run repeatedly:
int raw = analogRead(A5);
Serial.print("raw:");
Serial.print(raw);
Serial.print(",");
Serial.print(Thermister(raw));
Serial.println("c");
delay(500);
}
代码本身比较简单,应该没有什么问题,但是实际串口监视器中输出的数据却没有变化,一直都是如下的数据
raw:1023,334.94c
raw:1023,334.94c
raw:1023,334.94c
raw:1023,334.94c
raw:1023,334.94c
raw:1023,334.94c
raw:1023,334.94c
raw:1023,334.94c
raw:1023,334.94c
raw:1023,334.94c
通过查找资料,看到了参考文献3,里面有一个热敏电阻测温度的原理图,图片如下:

根据参考文献2和3,计算热敏电阻的温度值需要一系列的参数值,但是这个模拟温度传感器的热敏电阻不知道具体型号,其它的参数也一无所知,所以对它的使用也只能到这里了。
参考资料:
[1]http://blog.sina.com.cn/s/blog_5e3f971b0100j8h0.html
[2]http://oszine.com/arduino%E4%BC%A0%E6%84%9F%E5%99%A8%E8%BF%9E%E8%BD%BD%E4%B9%8B%E6%B8%A9%E5%BA%A6%E6%B5%8B%E9%87%8F%E7%AF%87/
[3]http://blog.youkuaiyun.com/al_shawn/article/details/51287759