温度传感器测量温度,也是比较简单的。
模块资料:
模块要接在扩展板的模拟区J12,电源接1.8或3.3
模拟读取直接调用库函数*data = analogRead(_analog_pin);即可
我们只需要对数据进行转换
代码:
- // Calculations for Temp Sensor - BD1020
- // Math: ADC_Voltage = sensorValue * (5V/1024)
- // Tempurature = - (1000 * ADC_Voltage - 1546) / 8.2
- float BD1020::convert_degree(unsigned short data)
- {
- float tmp, temp;
- tmp = (float)data * 5 / 1024;
- temp = -(1000 * tmp - 1546) / 8.2;
-
- return (temp);
- }
通过手指触摸PD区,测量温度变化结果:
曲线数据:
这个比较简单。