Puzzle - Infrared Temperature Sensor 红外温度传感器

来自Duinopeak_COM
跳转至: 导航搜索

产品简介

红外温度传感器通过接收物体发出的红外线来测量其温度,输出电压为0~1.1V。

Puzzle Infrare temprature sensor top.jpgPuzzle Infrare temprature sensor back.jpg

参数规格

  • 工作电压: 3-5V
  • 工作电流: 160-200 uA
  • 检测温度: -10~100°C
  • 保持时间: 2S
  • 工作温度: -10~80 °C

应用实例

注意:为了让测量得到正确的数值,请确定你把红外传感器的距离和被测量物体的距离保持在正确的距离范围(D的距离比上S的距离必须要小于0.5的范围 ),如下图所示。
Dsdiagram.jpg
这个示例演示了如何用红外温度传感器测量温度,然后通过Serial Monitor或者串口LCD(我们程序中屏蔽了LCD函数,方便用户直接通过Serial Monitor显示)显示测量结果。 将其接至模拟口,然后下载File:Demo Code,并打开。 在测量之前,需要对传感器进行校准:
Puzzle Infrare temprature sensor connection.jpg
步奏一:调节传感器电压 下载代码到主控板后,将传感器放置在常温下5分钟,然后打开Serial Monitor 查看传感器输出电压。当环境温度和测量温度相等时,红外温度传感器输出电压是0V,所以我们需要在代码中调整offset。

步奏二:校准检测距离 我们经过试验验证,最佳的检测距离是9CM,但也不能保证不存在误差,因此,在使用前需要进行校准,分别将传感器对准冰水混合物和开水,来确定0℃和100℃。 校准时将传感器对准冰水混合物,上下移动距离,当显示的数值为0℃时,记下测量的距离;对准开水时同理。 同样的物体在不同的距离下,可以得到不同的温度结果。你可以参考代码里提供的几种温度距离,或是自己通过上面的校准方式,确定不同距离下的温度变化。

#include <math.h>
//#include <NewSoftSerial.h>       //if display in LCD
//#include <SerialLCD.h>           //if display in LCD
//#include "temp.h"
 
const int temp_analog_in = A0;  // Analog input pin connect to temperature sensor SUR pin
const int objt_analog_in = A1;  // Analog input pin connect to temperature sensor OBJ pin
float temp_calibration=0;       //this parameter was used to calibrate the temperature
//float objt_calibration=0.000; //this parameter was used to calibrate the object temperature
float temperature_range=10;    //we make a map of temperature-voltage according to sensor datasheet. 10 is the temperature step when sensor and 
//object distance is 9CM.
float offset_vol=0.014;        //this parameter was used to set the mid level voltage,when put the sensor in normal environment after 10 min,
//the sensor output 0.For example,the surrounding temperature is 29℃,but the result is 27 via the sensor,
//you should set the reerence to 0.520 or more,according to your sensor to change.
//the unit is V

//SerialLCD slcd(11,12);
float tempValue = 0; 
float objtValue= 0;  
float current_temp=0;
float temp=0;
float temp1=0;
float temp2=0;
unsigned int temp3=0;
const float reference_vol=0.500;
unsigned char clear_num=0;//when use lcd to display
float R=0;
float voltage=0;

long res[100]={
 318300,302903,288329,274533,261471,249100,237381,226276,215750,205768,
 196300,187316,178788,170691,163002,155700,148766,142183,135936,130012,
 124400,119038,113928,109059,104420,100000,95788,91775,87950,84305,
 80830,77517,74357,71342,68466,65720,63098,60595,58202,55916,
 53730,51645,49652,47746,45924,44180,42511,40912,39380,37910,
 36500,35155,33866,32631,31446,30311,29222,28177,27175,26213,
 25290,24403,23554,22738,21955,21202,20479,19783,19115,18472,
 17260,16688,16138,15608,15098,14608,14135,13680,13242,12819,
 12412,12020,11642,11278,10926,10587,10260,9945,9641,9347,
 9063,8789,8525,8270,8023,7785,7555,7333,7118,6911};

float obj [13][12]={
 /*0*/  { 
   0,-0.274,-0.58,-0.922,-1.301,-1.721,-2.183,-2.691,-3.247,-3.854,-4.516,-5.236  }
 , //
 /*1*/  { 
   0.271,0,-0.303,-0.642,-1.018,-1.434,-1.894,-2.398,-2.951,-3.556,-4.215,-4.931  }
 ,  //→surrounding temperature,from -10,0,10,...100
 /*2*/  { 
   0.567,0.3,0,-0.335,-0.708,-1.121,-1.577,-2.078,-2.628,-3.229,-3.884,-4.597  }
 ,   //↓object temperature,from -10,0,10,...110
 /*3*/  { 
   0.891,0.628,0.331,0,-0.369,-0.778,-1.23,-1.728,-2.274,-2.871,-3.523,-4.232  }
 ,
 /*4*/  { 
   1.244,0.985,0.692,0.365,0,-0.405,-0.853,-1.347,-1.889,-2.482,-3.13,-3.835  }
 ,
 /*5*/  { 
   1.628,1.372,1.084,0.761,0.401,0,-0.444,-0.933,-1.47,-2.059,-2.702,-3.403  }
 ,
 /*6*/  { 
   2.043,1.792,1.509,1.191,0.835,0.439,0,-0.484,-1.017,-1.601,-2.24,-2.936  }
 ,
 /*7*/  { 
   2.491,2.246,1.968,1.655,1.304,0.913,0.479,0,-0.528,-1.107,-1.74,-2.431  }
 ,
 /*8*/  { 
   2.975,2.735,2.462,2.155,1.809,1.424,0.996,0.522,0,-0.573,-1.201,-1.887  }
 ,
 /*9*/  { 
   3.495,3.261,2.994,2.692,2.353,1.974,1.552,1.084,0.568,0,-0.622,-1.301  }
 ,
 /*10*/  { 
   4.053,3.825,3.565,3.27,2.937,2.564,2.148,1.687,1.177,0.616,0,-0.673  }
 ,
 /*11*/  { 
   4.651,4.43,4.177,3.888,3.562,3.196,2.787,2.332,1.829,1.275,0.666,0  }
 ,
 /*12*/  { 
   5.29,5.076,4.83,4.549,4.231,3.872,3.47,3.023,2.527,1.98,1.379,0.72  }
};

float binsearch(long x)// this function used for measure the surrounding temperature
{
 int low,mid,high;
 low=0;
 //mid=0;
 high=100;
 while (low<=high)
 {
   mid=(low+high)/2;
   if(x<res[mid])
     low= mid+1;
   else//(x>res[mid])
   high=mid-1;
 }
 return mid;
}

float arraysearch(float x,float y)//x is the surrounding temperature,y is the object temperature
{
 int i=0;
 float tem_coefficient=100;//放大器倍数100	
 i=(x/10)+1;//环境温度			
 voltage=(float)y/tem_coefficient;//转化后对应的原始电压		
 //Serial.print("sensor voltage:\t");		
 //Serial.print(voltage,5);	
 //Serial.print("V");			
 for(temp3=0;temp3<13;temp3++)		
 {			
   if((voltage>obj[temp3][i])&&(voltage<obj[temp3+1][i]))				
   {			
     return temp3;					
   }			
 }
}
float temp_measure()
{  
 unsigned char i=0;
 float current_temp1=0;	  
 int signal=0;	  
 tempValue=0;

 for(i=0;i<10;i++)       //	  
 {		  
   tempValue+= analogRead(temp_analog_in); 		  
   delay(10); 	  
 }	  
 tempValue=tempValue/10;	  
 temp = tempValue*1.1/1023;	  
 R=2000000*temp/(2.50-temp);	  
 signal=binsearch(R);	  
 current_temp=signal-1+temp_calibration+(res[signal-1]-R)/(res[signal-1]-res[signal]);
 //current_temp1=current_temp;
 //slcd.setCursor(0,1);
 //slcd.print("sur T:");
 //slcd.print((int)current_temp1,DEC);
 Serial.print("Surrounding temperature:");
 Serial.print(current_temp);
 return current_temp;
}

float objt_measure()
{
 unsigned char i=0;  
 unsigned char j=0;  
 float sur_temp=0;  
 unsigned int array_temp=0;  
 float temp1,temp2; 
 float final_temp=0;
 objtValue=0;	
 for(i=0;i<10;i++)
 {
   objtValue+= analogRead(objt_analog_in); 
   delay(10); 
 }       
 objtValue=objtValue/10;
 temp1=objtValue*1.1/1023;//+objt_calibration; 
 sur_temp=temp1-(reference_vol+offset_vol);             
 Serial.print("\t Sensor voltage:");		
 Serial.print(sur_temp,3);	
 Serial.print("V");	
 //slcd.setCursor(11,1);    
 //slcd.print((int)(temp1*10000),DEC);     
 array_temp=arraysearch(current_temp,sur_temp*1000);        
 temp2=current_temp;        
 temp1=(temperature_range*voltage)/(obj[array_temp+1][(int)(temp2/10)+1]-obj[array_temp][(int)(temp2/10)+1]);        
 final_temp=temp2+temp1;        
 if((final_temp>100)||(final_temp<=-10))
 {
   Serial.println ("\t out of range!");
 }
 else
 {
   Serial.print("\t object temperature:");		
   Serial.println(final_temp,2); 
 }
 ////////////////////////////////////////////////////
 //The fllowing code is used for display by serialLCD
   /*
       slcd.setCursor(0,0); 
  	slcd.print("obj T:");  
  	if((final_temp>=0)&&(final_temp<=100))
  	{       		
  		slcd.print(final_temp,DEC);        		 		       
  	}       
  	else if((final_temp<0)&&(final_temp>=-10))      	
  	{
  		slcd.setCursor(10,0);		
  		slcd.print('-');		
  		slcd.print(abs(final_temp),DEC);
  	}
  	else
  		{
  			slcd.setCursor(5,0);  
  			slcd.print("out of range");
  			}
    */
 //////////////////////////////////////////
}

void setup() 
{
 Serial.begin(9600); // initialize serial communications at 9600 bps:
 //slcd.begin();//Add while using LCD to display
 //slcd.backlight();//Turn on the backlight of LCD while using LCD to display
 analogReference(INTERNAL);//set the refenrence voltage 1.1V,the distinguishability can up to 1mV.
 //analogReference(INTERNAL1V1);//(mega only)set the refenrence voltage 1.1V,the distinguishability can up to 1mV.
}
//If use LCD to display, adding below code to clear the screen in time
void loop()
{
 temp_measure();
 objt_measure();

 /*
      if(clear_num==10)
  		{
  			slcd.clear();
  			clear_num=0;			
  			}
  	else
  		clear_num++;   
  */
}

注意: 1) 这个示例的代码不支持Atmega168芯片.

2) 为了获得准确的测量,距离(D)和角度(S)的比值D:S必须小于0.5。


资源


Puzzle - Infrared Temperature Sensor 红外温度传感器原理图PDF: 文件:Puzzle Infrared Temperature Sensor schematic.pdf

Puzzle - Infrared Temperature Sensor 红外温度传感器芯片OTP-538数据手册: 文件:Puzzle Infrared Temperature Sensor OTP-538Udatasheet.zip

Puzzle - Infrared Temperature Sensor 红外温度传感器演示程序: 文件:Puzzle Infrared temperature demo code.zip

Puzzle - Infrared Temperature Sensor 红外温度传感器串口LCD显示温度程序: 文件:Puzzle Infrared temperature demo code with serialLCD.zip

如何购买

Duinopeak 官方淘宝商城
Infrared Temperature Sensor 红外温度传感器购买链接

支持

如果你有什么建议或者好的点子, 你可以来我们的DuinoPeak论坛参与讨论.

外部链接

链接到外部网页将会给你提供更多应用创意,文档/数据表或软件库

视频