怎样用MLX90614和Arduino构建红外测温仪

电子说

1.2w人已加入

描述

在本文中,我将解释如何通过红外线测量表面温度。使用这项技术,我们可以简单地通过向表面发送红外波并分析返回传感器的波来收集温度信息。

有许多不同类型的传感器可用于测量温度。 LM35或DS18B20温度传感器根据直接施加在传感器设备表面的热量提供输出。但是,对于极热的情况(例如明火),您无法使用基于接触的传感器来检测准确的温度。

如果你想用非接触式方法(我们为这个项目做)检测温度,红外线温度计传感器是最好的解决方案。因此,我们将使用Melexis的MLX90614红外测温仪进行此项目。 MLX90614传感器使用非接触式温度传感来收集温度信息,而不会触及任何特定表面。

红外线温度计的工作原理

虽然人眼看不到,但所有物体都会发出红外光线,浓度会因温度而异。通过检测红外线,我们可以感知温度范围。 MLX90614温度计传感器使用这一原理。

MLX90614是一款功能强大的红外传感器件,具有极低噪声放大器和17位ADC。它可以为温度计提供高精度和高分辨率。关于MLX90614的最佳部分是它使用工厂的数字SMBus进行校准。这意味着它将提供0.02°C的高分辨率输出,并可连续传输-20至120°C的测量温度。

现在我们了解传感器的工作原理,让我们深入了解项目!

必需材料

Arduino

字符LCD 16x2

MLX90614

LCD屏蔽(可选)

接线

MLX 90614温度计具有I2C通信线路,因此我们可以将此传感器与Arduino连接,无需任何额外电路。如下图所示连接所有内容。您可以使用LCD 16X2屏蔽或连接独立LCD,如Fritzing图中所述。

适用于Arduino LCD Shield

上传源代码

红外测温仪

将以下源代码复制并粘贴到Arduino IDE。仔细检查连接后,上传代码。

/*

* Non-contact Thermometer with GY - 906 module

* Support for the MLX90614 sensor on the I2C bus

* SDA line = A4

* SCL line = A5

* Sensor supply with 5V

*/

#include

#include

LiquidCrystal lcd (8, 9, 4, 5, 6, 7);

int address = 0xb4; // Sensor address MLX90614

int erc = 0; // Variable holding the PEC value

int dataH = 0; // The second byte of data

int dataL = 0; // The first byte of data

double tempnalsb = 0.02; // Variable by which the digital value will be multiplied

double temperature = 0; // Variable holding the temperature

void setup () {

i2c_init (); // Initialization of the I2C bus

lcd.begin (16, 2); // Initialize the display

}

void loop () {

i2c_start_wait (address + I2C_WRITE); // Start I2C communication in write mode

i2c_write (0x07); // Write the value 0x07 (select the register Tobj1)

i2c_rep_start (address + I2C_READ); // Restart I2C communication at the read address

dataL = i2c_readAck (); // Read the first byte of data

dataH = i2c_readAck (); // Read the second byte of data

erc = i2c_readNak (); // Read the third (unimportant) data byte

i2c_stop (); // End of I2C transmission

temperature = (double) (((dataH & 0x007F) 《《 8) + dataL); // Create a 16-bit variable consisting of two one-byte variables

temperature = temperature * tempnalsb; // For one bit 0.02 K, the result of this operation is the temperature in Kelvin

temperature = temperature - 273.15; // Conversion to Celsius degrees

lcd.setCursor (0,0); // Display (first LCD line)

lcd.print (“Object =”);

lcd.print (temperature);

lcd.print (“”);

lcd.write (0xDF); // Degree sign

lcd.print (“C”);

i2c_start_wait (address + I2C_WRITE);

i2c_write (0x06); // Select the ambient temperature register

i2c_rep_start (address + I2C_READ);

dataL = i2c_readAck ();

dataH = i2c_readAck ();

erc = i2c_readNak ();

i2c_stop ();

temperature = (double) (((dataH & 0x007F) 《《 8) + dataL);

temperature = temperature * tempnalsb;

temperature = temperature - 273.15;

lcd.setCursor(0,1); // Display (second LCD line)

lcd.print (“Ambient =”);

lcd.print (temperature);

lcd.print (“”);

lcd.write (0xDF);

lcd.print (“C”);

delay (200); // Delay 200ms

}

有很多项目可以派上红外温度传感器,例如测量液体或热触摸表面。因为它不需要直接接触,所以在这些情况下MLX90614将是一个很好的选择。

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
评论(0)
发评论
123ABC123_ 2021-04-04
0 回复 举报
想问用什么库呢? 收起回复

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分