Temperature Sensor Module(KY-013) CN: 두 판 사이의 차이
(새 문서: {{#seo:|title=ArduWiki:Arduino 模拟温度检测模块指南|title_mode=append|keywords=Arduino, 信息科学, 创客学习, 项目评估, 模拟温度检测模块, Arduino项目, 毕业设计, Arduino示例代码|description=如何使用Arduino控制模拟温度检测模块(基本信息、电路、示例代码)。适用于信息与创客教学。}}center|class=coders100 该模块通过检测温度并以模拟信号...) |
(차이 없음)
|
2025년 3월 27일 (목) 18:44 기준 최신판

该模块通过检测温度并以模拟信号的方式输出。
规格
- 工作电压 [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);
}
执行结果
用手包住温度感应部分时,串口监视器将输出温度的变化。
