wiz*_*tjh 2 microcontroller arduino
第一个传感器是我的lm335z输出.
int firstSensor = 0;
int secondSensor = 0;
int thirdSensor = 0;
int inByte = 0;
void setup()
{
Serial.begin(9600);
establishContact(); // send a byte to establish contact until receiver responds
}
void loop()
{
if (Serial.available() > 0) {
inByte = Serial.read();
firstSensor = analogRead(0);
delay(10);
secondSensor = analogRead(1);
thirdSensor = analogRead(2);
Serial.print(firstSensor, DEC);
Serial.print(",");
Serial.print(secondSensor, DEC);
Serial.print(",");
Serial.println(thirdSensor, DEC);
}
}
void establishContact() {
}
Run Code Online (Sandbox Code Playgroud)
根据其数据表,温度输出将在10mV/K时变化.但如果您在已知参考温度下找到参考电压,则可以使用数据表中的这个有用的公式:
V_out = V_ref * T_out/T_ref 这相当于 T_out = T_ref * (V_out/V_ref)
所以说你的电压在25摄氏度或298.15开氏度时为2.982V(这在数据表中有建议),那么你可以将公式设置为:
T_out = (298.15 Kelvin)(V_out/2.982V)-273.15
因此,假设您已经可以将模拟读数转换为电压*,只需插入测量的电压,这应该以温度C为单位给出温度.
*Arduino内置10位ADC,可读取的最大电压为5v.因此,您可以将每步ADC的5v/1024 ADC步长= 0.00488V.(即V_out = firstSensor*0.00488).因此插入V_out,等式变为:
T_out = (298.15)(firstSensor*0.001637)-273.15 其中0.001637 = 0.00488/2.982.