基于STM32的人体红外测温

文章目录

  • 前言
  • 一、清单
  • 二、实现功能
  • 三、部分程序
    • 读取温度程序
    • 计算并返回温度值程序
  • 四、实现效果
    • 1、实物模块介绍
    • 2、正常测温展示
    • 3、超温报警展示
  • 五、源码及资料


前言

本次介绍的项目是 基于STM32的人体红外测温枪的设计,大家参考可用于课程实验毕业设计,希望对各位有所帮助!喜欢的小伙伴们可以加我企鹅:970484728 互相学习,有任何问题欢迎来讨论!


一、清单

基于STM32的人体红外测温_第1张图片

二、实现功能

1. 每当按下S2按键温度阈值 加0.1,按下S3按键温度阈值 减0.1
2. 当红外测温传感器测得人体温度大于设定温度阈值,则红色LED亮和蜂鸣器响。
3. 测得温度大于温度阈值时,此时LOED第四行显示“温度超过阈值”,否则第四行不显示任何消息。

三、部分程序

读取温度程序

u16 SMBus_ReadMemory(u8 slaveAddress, u8 command)
{
    u16 data;			// Data storage (DataH:DataL)
    u8 Pec;				// PEC byte storage
    u8 DataL=0;			// Low data byte storage
    u8 DataH=0;			// High data byte storage
    u8 arr[6];			// Buffer for the sent bytes
    u8 PecReg;			// Calculated PEC byte storage
    u8 ErrorCounter;	// Defines the number of the attempts for communication with MLX90614

    ErrorCounter=0x00;	// Initialising of ErrorCounter
	slaveAddress <<= 1;	//2-7位表示从机地址 从机地址左移一位,把读写位空出来
	
    do
    {
repeat:
        SMBus_StopBit();			    //If slave send NACK stop comunication
        --ErrorCounter;				    //Pre-decrement ErrorCounter
        if(!ErrorCounter) 			    //ErrorCounter=0?
        {
            break;					    //Yes,go out from do-while{}
        }

        SMBus_StartBit();				//Start condition
        if(SMBus_SendByte(slaveAddress))//Send SlaveAddress 最低位Wr=0表示接下来写命令
        {
            goto	repeat;			    //Repeat comunication again
        }
        if(SMBus_SendByte(command))	    //Send command
        {
            goto	repeat;		    	//Repeat comunication again
        }

        SMBus_StartBit();					//Repeated Start condition
        if(SMBus_SendByte(slaveAddress+1))	//Send SlaveAddress 最低位Rd=1表示接下来读数据
        {
            goto	repeat;             	//Repeat comunication again
        }

        DataL = SMBus_ReceiveByte(ACK);	//Read low data,master must send ACK
        DataH = SMBus_ReceiveByte(ACK); //Read high data,master must send ACK
        Pec = SMBus_ReceiveByte(NACK);	//Read PEC byte, master must send NACK
        SMBus_StopBit();				//Stop condition

        arr[5] = slaveAddress;		//
        arr[4] = command;			//
        arr[3] = slaveAddress+1;	//Load array arr
        arr[2] = DataL;				//
        arr[1] = DataH;				//
        arr[0] = 0;					//
        PecReg=PEC_Calculation(arr);//Calculate CRC 数据校验
    }
    while(PecReg != Pec);//If received and calculated CRC are equal go out from do-while{}

	data = (DataH<<8) | DataL;	//data=DataH:DataL
    return data;
}

计算并返回温度值程序

 /*******************************************************************************
 * 函数名: SMBus_ReadTemp
 * 功 能: 计算并返回温度值
 * return : SMBus_ReadMemory(0x00, 0x07)*0.02-273.15
*******************************************************************************/
float SMBus_ReadTemp(void)
{   
	float temp;
	temp = SMBus_ReadMemory(SA, RAM_ACCESS|RAM_TOBJ1)*0.02-273.15;
	return temp;
}

四、实现效果

1、实物模块介绍

(S1按键用来切换模式:①测人体温度模式②测物体温度模式,默认测人体温度模式)

2、正常测温展示

基于STM32的人体红外测温_第2张图片

3、超温报警展示

基于STM32的人体红外测温_第3张图片

五、源码及资料

链接:https://pan.baidu.com/s/1VQC1QsEhQ3TEtwpAbV-5uw
提取码:点击提取
(其中还包含:源程序、MLX90614资料、OLED资料、原理图、实验报告、STM32软件及资料)

不需要源码的不强求,仅供学习参考!

你可能感兴趣的:(STM32,stm32,单片机,红外测温)