Temperature Sensor Module(KY-013) CN

아두위키 : Arduwiki

该模块通过检测温度并以模拟信号的方式输出。

规格

  • 工作电压 [V]:5
  • 误差范围 [°C]:-5 ~ +5

示例使用硬件

  • Arduino board
  • 跳线
  • 模拟温度检测模块

接线方式

Arduino UNO 模拟温度检测模块
5V +
GND -
A0 S

示例代码

本示例读取并打印温度值。

const int ThermistorPin = A0;
const float R1 = 10000;
const float c1 = 0.001129148, c2 = 0.000234125, c3 = 0.0000000876741;
int Vo;
float logR2, R2, T;

void setup() {
  Serial.begin(9600);
}

void loop() {
  Vo = analogRead(ThermistorPin);
  R2 = R1 / (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
  T = T - 273.15;
  Serial.print("Temperature: ");
  Serial.print(T);
  Serial.println(" C");
  delay(500);
}

执行结果

用手包住温度感应部分时,串口监视器将输出温度的变化。