简单的温度记录器使用arduino(°C和°F)。

本项目是一个使用arduino uno和arduino IDE中的串行监控功能的简单的USB温度记录系统。系统每2秒监测一次温度,并显示在arduino串行监视器上。温度用摄氏度和华氏度表示。系统通过USB接口与PC机连接。温度传感器采用LM35。

LM35是美国国家半导体公司的三端线性温度传感器。它可以测量温度从-55℃到+150℃。LM35的电压输出增加10mV每摄氏度的温度上升。LM35可以从5V电源工作,待机电流小于60uA。LM35的引脚如下图所示

线路图。温度日志电路arduino

温度传感器LM35通过模拟输入引脚A0、A1、A2与Arduino接口。模拟输入引脚A0调高,作为LM35的5V电源引脚。模拟输入引脚A2调低,作为LM35的接地引脚。模拟输入引脚A1设置为输入,LM35的电压输出通过该引脚连接到arduino。这个方案非常有用,因为你可以直接将LM35插入模拟输入母头,而不需要外部连接线。arduino板由PC通过USB线供电,这个电路不需要外部供电。USB接口也作为arduino与PC之间的通信媒介。

程序。

int t = 0;int vcc = A0;//设置模拟输入A0为LM35的+5V源int sensor=A1;//设置A1为传感器输入int gnd=A2;//设置模拟输入A2为LM35浮子温度接地;浮动tempc;浮动tempf;void setup() {pinMode(vcc,OUTPUT);pinMode(接地、输出);pinMode(传感器、输入); digitalWrite(vcc,HIGH); // sets analog input A0 HIGH digitalWrite(gnd,LOW); // sets analog input A2 LOW Serial.begin(9600); // sets the baud rate at 9600 } void loop() { delay(2000); // calls a 2 second delay t=t+2; // increments the time by 2 every two seconds temp=analogRead(sensor); // reads the LM35 output tempc=(temp*5)/10; // converts the digital value into temperature degree C tempf=(tempc*1.8)+32; // converts degree C to degree F Serial.println("..............."); Serial.println("Temperature logger"); Serial.print("Time in sec = "); // prints the time on serial monitor window Serial.println(t); Serial.print("Temperature in deg C = "); // prints the temperature in degreeC Serial.println(tempc); Serial.print("Temperature in deg F = "); // prints the temperature in degreeF Serial.println(tempf); }

关于这个项目。

LM35的电压输出接arduino的模拟输入A1。该引脚的电压将与温度成正比,该电压使用analogRead功能读取。analogRead功能将读取特定模拟输入引脚上的电压(范围为0到5),并将其转换为0到1023之间的数字值。例如,如果温度为29℃,LM35的输出将是290mV。模拟函数的结果将是290mV/(5/1023) =59。必须有一些方法将这个59转换为29.0,以便在串行监视器窗口中显示。59乘以5,然后除以10。结果将是°C的温度,它使用串行显示。打印功能。然后将其转换为°F,公式如下:°F=(°C*1.8)+32。温度也显示在°F。 The serial monitor can be accessed from the Tools tab in the arduino IDE. The shortcut for serial monitor is ctrl+shift+M. The snapshot of the serial monitor window is shown in the figure below.

arduino连续监控

作者

7评论

  1. 艾萨克·温菲尔德

    使用处理器输出引脚LM35的供应是好的(电压的精确值不重要),但使用信号引脚接地是有点问题。引脚可能不会被精确地驱动到零伏,无论有什么电压,都会增加到LM35的输出,使读数不正确一些未知的量。更糟糕的是,信号引脚上的非零电压可能会根据芯片的温度而变化,甚至从一个设备到另一个设备。

    以撒

    • 乔乔

      @Isaac

      我们这样做是为了方便连接(只是为了避免面包板)。出于演示目的或教育目的,这种方法很好。此外,它还教授了在模拟引脚上使用digitalWrite功能的可能性。当涉及到现实世界的实施时,我们的意见是一致的。我们一直建议使用Arduino合适的GND引脚连接LM35的接地。

      谢谢你的评论。

  2. 约翰

    嗨。

    看起来你在电路图上混合了GND和LM35的Vout引脚。

    干杯!

Baidu